dcsimg
How to obtain 8 byte unique number for String using DES
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rana_Aich
Posted On:   Tuesday, August 30, 2005 07:34 PM

Hi All, Is there any way to generate a unique 8 byte number representation of String? I know it can be done with DES encryption (while MD5 gives 16 bytes number). My requirement is: Every time a String is passed - my static method should return the same unique number - all the time. i.e A String "AAAAAA" will return same unique number all the time. How can I achieve this (8 byte number) by DES Encryption or any other encryption? My Static method looks as below: public static BigInteger getEncodedHexString(String str) throws Exception { byte[] ciphertext; KeyGenerator    More>>

Hi All,


Is there any way to generate a unique 8 byte number representation of String?



I know it can be done with DES encryption (while MD5 gives 16 bytes number).
My requirement is:



Every time a String is passed - my static method should return the same unique number - all the time.


i.e A String "AAAAAA" will return same unique number all the time. How can I achieve this (8 byte number) by DES Encryption or any other encryption?





My Static method looks as below:


			

public static BigInteger getEncodedHexString(String str)
throws Exception
{
byte[] ciphertext;
KeyGenerator keygen = KeyGenerator.getInstance("DES");
SecretKey desKey = keygen.generateKey();
//keygen.init(56);
Cipher c = Cipher.getInstance("DES");
c.init(Cipher.ENCRYPT_MODE, desKey);
ciphertext = c.doFinal(str.getBytes("UTF-8"));

return new BigInteger(ciphertext);
}


Thanking all in advance.    <<Less
About | Sitemap | Contact