Archived Forum Post

Index of archived forum posts

Question:

C# - Example using crypt.Salt and crypt.SecretKey

Feb 18 '13 at 14:49

I'd like to implement a SecretKey and Salt. What I'd like to achieve are two things.

  1. Be able to use a SecretKet to add 1 layer of security. I'm aware it only applies to a few algorithms. And to decrypt, the SecretKey needs to be known.
  2. Salt value so each time you encrypt, a different value is given on output.

Any example would be great. Reference docs don't say much.


Answer

In my opinion, your solution is to use AES encryption (CBC mode) w/ an IV (initialization vector) that is different each time. Think of the IV as the "salt". There are examples at http://www.example-code.com/ for AES encryption.