Wednesday, April 9, 2008

Triple DES : JAVA coding

As my final year project are done, i would like to share some coding that i use. Before this i have post on DES, now i am sharing with you all on triple DES. In the name of open source..

Triple DES is also known as TDES or, more standard, TDEA (Triple Data Encryption Algorithm). The convention to use DES (the standard) when DEA (the algorithm) is intended is so widespread that in order to avoid confusion the term DES is used throughout this article. On the other hand, since there are variations of TDES which use two different keys (2TDES, officially 2TDEA) and three different keys (3TDES, officially 3TDEA) the non-standard abbreviation 3DES is confusing and should be avoided. [source : wikipedia]

3DES are just like DES but it used two or three different keys. The key size is at least 56 times two equal 112 bits. The DES algorithm use 56 bits as for 3DES, it use 112 bits (56 + 56) or 168 bits(56 +56 +56).
byte[] salt = {
(byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
(byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99

};

IvParameterSpec iv = new IvParameterSpec(salt);

byte[] raw = pass.getBytes(); //get byte of the password
SecretKeySpec skeySpec = new SecretKeySpec(raw, "DESede");

Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec , iv );

Take note that the pass is the variable for password. If you got something to ask, feel free to post a comment.

Peace upon you all

4 comments:

  1. I'm looking for encryption source codes in java ( including AES,DES,RSA,) which don't use library functions, and have all steps in a plain program or at least somehow that tracing each step of encryption in the program be easy.


    i 'll be happy if you could help me find them on web

    ReplyDelete
  2. you can search for bouncycastle library..i think it have those encryption algo.

    ReplyDelete