I know that we can define the key explicitly using the below line. For 3des the key length should be 24 bytes, if I am not wrong.
Dim Newkey() As Byte = Convert.FromBase64String("24 bytes enter here")
something like
Dim Newkey() As Byte = Convert.FromBase64String("c:\temp\mykey.pem")
- How do i make sure that the file gives back 24 bytes of data, for 3des encryption?
- What/How do i generate such a file?
TripleDES.GenerateKey, retrieve the key property. This will generate keys that should be compatible with TripleDES, then callConverter.ToBase64StringPlease look up a tutorial of creating/reading textual files yourself, using FromBase64String on a file name won’t work.
http://msdn.microsoft.com/en-us/library/system.security.cryptography.symmetricalgorithm.generatekey.aspx#Y0
Note that 16 byte keys may be used for TripleDES (ABA keys) as well as 24 byte (ABC) keys. Also note that there are weak keys in DES, and that keys include parity bits. Most implementations simply ignore the parity bits, but it is better to use a special key generation function to be sure they are set correctly.