-
encrypting password in xml
Hi
I want to encrypt the passwords which are stored in my xml configuration file. I read thru some articles and found some examples. But when i executed them, i get an exception,
java.security.NoSuchAlgorithmException: Algorithm DES not available
at javax.crypto.SunJCE_b.a(DashoA6275)
at javax.crypto.KeyGenerator.getInstance(DashoA6275)
at com.pfizer.groton.di.ceg.encryption.Encrypt.getEncryptedString(Encrypt.java:20)
at com.pfizer.groton.di.ceg.encryption.Encrypt.main(Encrypt.java:43)
The method is which i am using 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;
}
Any thoughts on why it is throwing this exception is greatly appreciated
Thanks,
radsat
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks