This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Convertion between SecretKey to String or byte Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Convertion between SecretKey to String or byte" Watch "Convertion between SecretKey to String or byte" New topic
Author

Convertion between SecretKey to String or byte

R.Lakshmi Narasimhan
Greenhorn

Joined: Feb 02, 2009
Posts: 5
Hi.I am not so good in Java. I need to know how to convert a DES SecretKey generated using Java to a String and vice versa. I am doing a program in java using DES. It is needed to convert the SecretKey (which is for encryption) to String and has to be sent to another process and in there, the same SecretKey has to be got from Srting (for Decryption).Please help me.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41026
    
  43
Welcome to JavaRanch.

You can obtain the bytes that make up the key by calling its getEncoded method. Using a reversible encoding like base-64 it is possible to create a String from that (and later transform it back into a byte[]).

A base-64 encoder/decoder can be found at http://www.source-code.biz/snippets/java/Base64Coder.java.txt


Ping & DNS - my free Android networking tools app
 
 
subject: Convertion between SecretKey to String or byte
 
Similar Threads
String to SecretKey
Encryption: communicating with other systems
BadPaddingException issue
Triple Des Pin Encryption
How to store SecretKey in database?