Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

encrypting password in xml file

843811Jun 15 2005 — edited Oct 5 2005
Hi

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 2 2005
Added on Jun 15 2005
10 comments
440 views