Get your CodeRanch badge!*
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39547
    
  27
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 - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convertion between SecretKey to String or byte
 
Similar Threads
Encryption: communicating with other systems
How to store SecretKey in database?
String to SecretKey
BadPaddingException issue
Triple Des Pin Encryption