wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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: 41128
    
  45
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convertion between SecretKey to String or byte
 
Similar Threads
BadPaddingException issue
How to store SecretKey in database?
Triple Des Pin Encryption
String to SecretKey
Encryption: communicating with other systems