• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Encryption using javax.crypto

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

In our client/server based application, I am adding encryption/decryption of password using javax.crypto package. I am planning to use DES algorithm. I have two questions here:

1. Usig the key: Can i use SecretKey class for generating the keys on client and server side, Like this :
SecretKey key = KeyGenerator.getInstance("DES").generateKey();

2. I want to return a String after I decrypt it. I got a sample implementation which returns a string using Base64 encoder/decoder. However I want to stay away from using these two classes.
What r the ways ?

Thanks,
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) As long as you have the same secret key on both side it is fine.
2) the encryption/decryption is designed to handle bytes other than characters. That is why in the sample you see based 64 encoded result. If you want to use string , you should change the byte[] to string by yourself. Just be careful with different charsets.

Thanks

Lin
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic