Friday, April 4, 2008

DES : JAVA

Today i am gonna post about DES aka Data Encryption Standard. Actually it's a little not-up-to-date if you are using this type of algorithm. But for education purpose it's ok..hee..My final year project used this algorithm cause it's the SUN JCE have it's library built in it. First we need to know what is DES.

DES used 56 bits key and used 64 bit block size. I take my Cryptography subject this year so it's really an advantage for me for my final year project which has been successfully done. DES considered not save anymore from attack because of the key length. They already develope a machine called COPACOBANA which used to key search for DES for 6.4 days.

The process are really complicated..trust me, i have don't the calculation for DES during my Cryptography subject..hate math=p hehe..below is the coding that i used for DES. Actually it's a Password Based Encryption or PBE for DES. It used Cipher Block Chaining mode and padding.
PBEKeySpec pbeKeySpec;
PBEParameterSpec pbeParamSpec;
SecretKeyFactory keyFac;

// Salt
byte[] salt = {
(byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
(byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
};

// Iteration count
int count = 20;

// Create PBE parameter set
pbeParamSpec = new PBEParameterSpec(salt, count);

String pass = "my secret";

try {

keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
pbeKey = keyFac.generateSecret(pbeKeySpec);
Cipher pbeCipher;
pbeCipher = Cipher.getInstance("PBEWithMD5AndDES/CBC/PKCS5Padding");
pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);

}

Anyway hope that the code above helps you all.have a nice days..wished me luck for my Cisco Network Competition Skills tomorrow.buh bye..

No comments:

Post a Comment