encrypting password in xml file
843811Jun 15 2005 — edited Oct 5 2005Hi
I want to encrypt the passwords in the xml. So I read some articles and found this method. I tried to use it in my progroam , it gives me an error, saying
java.security.NoSuchAlgorithmException: Algorithm DESede not available
The method is,
public static String getEncryptedString(String input)throws Exception{
Security.addProvider( new com.sun.crypto.provider.SunJCE() );
Key key = null;
KeyGenerator kg = KeyGenerator.getInstance("DES");
key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(Cipher.ENCRYPT_MODE, key);
byte[]inputBytes = input.getBytes("UTF8");
byte[] outputBytes = cipher.doFinal(inputBytes);
BASE64Encoder encoder = new BASE64Encoder();
String base64 = encoder.encode(outputBytes);
return base64;
}
Would appreciate if any one tells me why this error is thrown and how to get it working.
Thanks
radsat