[VS 2008] Strong encryption and hashing class - Updated! 31/August/2009
Updated - August/31/2009
FYI:
Someone asked me if one should use the whole algorithm to encrypt or hash; the answer is NO, if you want to encrypt a string (with AES or Rijndael) then just copy the region and paste it in your code, same thing goes for hashing. The code is divided into regions to serve that purpose.
Updates:
Added an enumeration to hold the cryptographic actions that can be performed (encryption or decryption).
Added a function to generate an IV from the given key (after playing around with it ).
Added an exception handler... Just in case the password isn't the right one.
Hello,
I have been working on this for a while now, I have based my work on Jenner's submission. Since I had noticed that it was for VS 2005, I decided to create my own, for VS 2008...
I have included AES for encryption and used SHA256 for hashing the strings, also some overloads so it'll handle more object types (to permit more "flexibility").
Even though AES and Rijndael ARE THE SAME ALGORITHMS, they have some particularities:
AES:
Has a fixed block size of 128bits.
Allows key sizes of 128, 192 and 256 bits.
Rijndael:
Allows block sizes of 128bits, 192bits and 256bits.
Permits the use of 64, 96, 128, 192, 256 bits key sizes.
(The block size is specific to each algorithm since it indicates which the size of the IV to be used or that is supported by one of these two algorithms.)