Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
C#
//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
Posted
Updated 16-Jun-14 22:06pm
v2

1 solution

 
Share this answer
 
Comments
londhess 17-Jun-14 4:15am    
I already tried above Cipher.html url. The key generated from Java and from .NET are differ. So if i encrypt the text using .NET and try to decrypt text using JAVA ,it will not work properly.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900