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 Reversible String to Number convertor 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 "Reversible String to Number convertor" Watch "Reversible String to Number convertor" New topic

Reversible String to Number convertor

Vijay Kashyap
Ranch Hand

Joined: Jul 30, 2001
Posts: 74

I have a requirement for generating reversible String to Number Conversion utility. Can somebody supply me the pointers to go about bulding this.

I am stating an example to clarify the need:

For input String 'Java Ranch' I need to generate a unique number which should be able to convert back to 'Java Ranch' string.

Arun Bommannavar
Ranch Hand

Joined: Jan 11, 2003
Posts: 53
My guess would be HashMap.

Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Well, it all depends on how much you would like to complicate it. One simple way would be to get bytes from the String and convert them to a number, and then conver the number back to bytes and get the String, provided that you can use the same encoding for both operations all the time.

Anohter way could be encryption. See Java Almanac for an example.
It is sorta covered in the JavaRanch Style Guide.
subject: Reversible String to Number convertor
Similar Threads
SHA Encryption System
Generate unique numbers from a table's primary key, to be used as an external reference.
Modify PDF content fetched as a blob from SQL server
Convertion between SecretKey to String or byte
Comparable conversion to Long