PasswordDerivedBytes .NET等效于JAVA [英] PasswordDerivedBytes .NET equivalent to JAVA

查看:118
本文介绍了PasswordDerivedBytes .NET等效于JAVA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.net和java中都使用了中断和解密。在.net方面,我使用passwordDerivedBytes为AES生成密钥和IV。任何人都可以告诉我JAVA中的等价物。因为我需要在.NET和JAVA中使用相同的密钥。我在两者中都使用了AES算法。

这是我的代码示例。所以请让我知道相当于JAVA。

I have used encruption and decryption in .net and java both. In .net side , i used passwordDerivedBytes for generating the keys and IV for AES. Can anyone tell me what is the equivalent in JAVA. As i need same key genaration in both .NET and JAVA. I used AES algorithm in both.
Here is my code sample. So please let me know the equivalent to JAVA.

//here password is input from user and it is in byte array.
PasswordDeriveBytes pdb =
              new PasswordDeriveBytes(password, // Change this //hjiweykaksd
              new byte[] { 0x43, 0x87, 0x23, 0x72 }); // Change this
           MemoryStream ms = new MemoryStream();
            Aes aes = new AesManaged();
            aes.Key = pdb.GetBytes(aes.KeySize / 8);

            aes.IV = pdb.GetBytes(aes.BlockSize / 8);
CryptoStream cs = new CryptoStream(ms,
              aes.CreateEncryptor(), CryptoStreamMode.Write);
            cs.Write(input, 0, input.Length);
            cs.Close();



提前谢谢


Thanks in advance

推荐答案

你需要使用< a href =http://docs.oracle.com/javase/7/docs/api/javax/crypto/Cipher.html> http://docs.oracle.com/javase/7/docs/api/javax /crypto/Cipher.html [ ^ ]



还有一些相当不错的教程 - 这是来自Torsten Horn的(翻译!)德语:< br $> b $ b

https://translate.googleusercontent.com /translate_c?depth=1&hl=de&ie=UTF8&prev=_t&rurl=translate.google.de&sl=de&tl=en&u=http://www.torsten-horn.de/techdocs / java的加密.htm& usg = ALkJrhjhYfLITn3EOx6nW5UMaQT64aiqHQ [ ^ ]





还有很多链接。玩得开心!
You need to use http://docs.oracle.com/javase/7/docs/api/javax/crypto/Cipher.html[^]

There are also some pretty good tutorials out there - here is a (translated!) german one from Torsten Horn:

https://translate.googleusercontent.com/translate_c?depth=1&hl=de&ie=UTF8&prev=_t&rurl=translate.google.de&sl=de&tl=en&u=http://www.torsten-horn.de/techdocs/java-crypto.htm&usg=ALkJrhjhYfLITn3EOx6nW5UMaQT64aiqHQ[^]


Also lots of links on there. Have Fun!


这篇关于PasswordDerivedBytes .NET等效于JAVA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆