How to use des/3des encyption

HiHow to use des/3des encryption for servlet.i m using Http protocol and form authentication, how to implement des/3des encryption.venadesh
[167 byte] By [venkadeshkumaresana] at [2007-10-1 23:35:21]
# 1

E.g.

/**

* Encrypt plain text with a specific algorithm and key.

*

* @param transformation Algorithm or algorithm/mode/padding string.

* @param key SecretKey to use for encrypting.

* @param plainText Text to encrypt.

* @return Encrypted text or null if failed.

* @throws Exception

*/

static public String encrypt(String transformation, SecretKey key, String plainText) throws Exception {

String result = null;

if (transformation != null && key != null && plainText != null) {

Cipher cipher = Cipher.getInstance(transformation);

cipher.init(Cipher.ENCRYPT_MODE, key);

byte[] stringBytes = plainText.getBytes(ICConstants.ENCODING_ISO88591); //encode

byte[] rawBytes = cipher.doFinal(stringBytes); //encrypt

BASE64Encoder encoder = new BASE64Encoder();

result = encoder.encodeBuffer(rawBytes); //encode bytes to base64 to get a string

}

return result;

}//encrypt()

with "DES" as the transformation parameter.

MartinHilperta at 2007-7-15 15:25:01 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 2
Hi I read this post of ursif u have implemented this, then can u give give me the code in java as well as javascripti wud b really gratefulThanks
Ashish_sea at 2007-7-15 15:25:01 > top of Java-index,Security,Other Security APIs, Tools, and Issues...