File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Websphere and the fly likes password Encryption in WSAD environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "password Encryption in WSAD environment" Watch "password Encryption in WSAD environment" New topic

password Encryption in WSAD environment

Monoj Barma

Joined: Oct 20, 2005
Posts: 9
Hi all,
i am working on the following program for encrypting password. Works fine as standalone java program, encrypt and decrypt the password but when i install the code in WSAD5.1 env i get Exception "final block not properrly padded" and "input lenght not multiple of 8 bytes".
Does anyone have any idea on this?

public class TripleDESPasswordEncrypt
private String characterEncoding = "ASCII";
//private String characterEncoding;
private Cipher encryptCipher;
private Cipher decryptCipher;

public TripleDESPasswordEncrypt() throws Exception
Provider ibmjce = new;
KeyGenerator kg=KeyGenerator.getInstance("DESede");
SecretKey key = kg.generateKey();
this.characterEncoding = characterEncoding;
this.encryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
this.encryptCipher.init(javax.crypto.Cipher.ENCRYPT_MODE, key);
System.out.println("Inside TripleDES instance");
this.decryptCipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
AlgorithmParameters alParam=AlgorithmParameters.getInstance("DESede");
this.decryptCipher.init(javax.crypto.Cipher.DECRYPT_MODE, key,alParam);

synchronized public String encrypt(String password) throws Exception
if (!password.matches("[ -~]{6,}"))
throw new IllegalArgumentException("Password must be printable ASCII");
System.out.println("Password ....................[" + password + "]");

byte[] passwordBytes = password.getBytes(characterEncoding);
byte[] encryptedPasswordBytes =this.encryptCipher.doFinal(passwordBytes);
String encodedEncryptedPassword =new String(encryptedPasswordBytes);
return encodedEncryptedPassword;

synchronized public String decrypt(String encodedEncryptedPassword) throws Exception

byte[] passwordBytes =this.decryptCipher.doFinal(encodedEncryptedPassword.getBytes());
String recoveredPassword = new String(passwordBytes,characterEncoding);
return recoveredPassword;


Thanks a lot!
jQuery in Action, 3rd edition
subject: password Encryption in WSAD environment
It's not a secret anymore!