TripleDES
All, I am very new to cryptography. Here is my multipart question.
1) I am trying to create a base64-encoded 192-bit value key using DESede algorithm.
2)what is the importance of an initialization vector (24 byte string). I am suposed to encrypt two values and I was asked to use an initialization vector (24 byte string) and send it along with the encrypted values.
any help (sample code, explanation) from the Cryptography experts will be greatly appreciated.
> All, I am very new to cryptography. Here is my
> multipart question.
> 1) I am trying to create a base64-encoded 192-bit
> value key using DESede algorithm.
OK - the JCE (http://java.sun.com/j2se/1.4.2/docs/guide/security/jce/JCERefGuide.html ) provides a way of doing this. There are plenty of on line tutorials which are best found with Google.
> 2)what is the importance of an initialization vector
> (24 byte string). I am suposed to encrypt two values
> and I was asked to use an initialization vector (24
> byte string) and send it along with the encrypted
> values.
The block size for DES is 8 bytes. Using a block mode each block is combined with the previous encrypted block and then encrypted. Obviously, the first block has no previous block so it requires a starting value which is the IV (initialization vector). For DES and DESede this is 8 bytes (24 bytes are not required).
The IV can be any set of 8 bytes. It can be 8 random bytes shipped as a prefix to the encrypted data OR it can be a fixed set of 8 bytes known to both the encryption and decryption process. When using a random IV it can be sent without any encoding because knowledge of it does not help an attacker. In general, it is better to use a random IV rather than a fixed IV.
>
> any help (sample code, explanation) from the
> Cryptography experts will be greatly appreciated.
Note - encrypted bytes will look very random and should not be converted to Strings using
String result = new String(encryptedBytes);
because in general this is not reversible. If you have to have a String representation then use Base64 or Hex encoding which is always reversible. Hex and Base64 encoders/decoders can be found using Google by searching for 긓akarta Commons Codec?