Encryption using Enterprise Library 5.0 Cryptography Block

Topics: Cryptography Application Block, General discussion
Oct 16, 2013 at 12:54 PM
Edited Oct 16, 2013 at 1:00 PM
hi,
We are using Enterprise library 5.0 Cryptography block for encrypting some strings in our application.

The encryption /decryption works fine, without any issue. But, when I was debugging into my code, I found that the Encrypted value generated is always different however the key remains the same. I am using rijndael symmetric key provider (and i admit I am not sure how it works :))

Just want to know, whether this is expected behaviour or is there something fishy behind the scene...
Oct 16, 2013 at 1:05 PM
Yes, this is expected behavior. An Initialization Vector is added to the encrypted value (and used during decryption). For background see http://en.wikipedia.org/wiki/Initialization_vector .

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Marked as answer by tamanas1 on 10/16/2013 at 11:20 PM
Oct 16, 2013 at 2:44 PM
Thanks Randy for your quick response.

I read the documentation and found that while decrypting, the same IV and key value must be used. While decrypting I am sure about key, but what about the IV? Does my encrypted string also stores an associated IV value with that?
Oct 16, 2013 at 4:00 PM
Yes, the IV gets prepended to the ciphertext. On decryption, the IV is extracted and used by the SymmetricAlgorithm.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Oct 17, 2013 at 7:22 AM
thanks again..