File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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: 42266
    
  64
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