knowing salt that used when encryption AES 256

I have a password like "abd123456", that I encrypt with AES-256 encryption. After Base-64 encoding, the result would be the 44 character string:

IXCgaa5igYxzKTRTP+PMT7Bt9iIWiF6EWLmnKqZtlXI=

How can I know the salt that the .NET Framework's RijndaelManaged AES encryption class used during encryption?

I know the plaintext that is being encrypted, and the encryption key. But how do I know the Salt used?

Upvotes: 1

Views: 654

Answers (1)

Ian Boyd
Ian Boyd

Reputation: 256881

You can read the salt from the .IV property of the AES encryption object.

From MSDN documentation:

The IV property is automatically set to a new random value whenever you create a new instance of one of the SymmetricAlgorithm classes.

Simply read the .IV after creating your encryptor. Then you can save the salt, or replace it with your own desired salt. Salt does not have to be secret, or even cryptographically random - it just has to be different each and every time.

Upvotes: 0

Related Questions