Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 126
Registered: ‎06-08-2009
My Device: Not Specified

Generate value using MD5 hash.

Hi All,

 

Can anybody provide me some sample code for  generating value using "MD5 hash" which takes string(name) in hex.

 

Thanks in advance.

Developer
Posts: 126
Registered: ‎06-08-2009
My Device: Not Specified

Re: Generate value using MD5 hash.

Hey anyone knows this?
Developer
Posts: 132
Registered: ‎02-11-2009
My Device: Not Specified

Re: Generate value using MD5 hash.

import net.rim.device.api.crypto.MD5Digest; public String hash(String data) { byte[] bytes = data.getBytes("UTF-8"); MD5Digest digest = new MD5Digest(); digest.update(bytes, 0, bytes.length); int length = digest.getDigestLength(); byte[] md5 = new byte[length]; digest.getDigest(md5, 0, true); // ... convert md5 to string. }

 

Something like that.

 

Cheers, Barak

Contributor
Posts: 14
Registered: ‎07-02-2012
My Device: BlackBerry 9930
My Carrier: BlackBerry

Re: Generate value using MD5 hash.

Ya..Thanks...It works...

Contributor
Posts: 14
Registered: ‎07-02-2012
My Device: BlackBerry 9930
My Carrier: BlackBerry

Re: Generate value using MD5 hash.

Hi..Thanks a lot..It works...
Highlighted
Contributor
Posts: 22
Registered: ‎05-04-2012
My Device: BlackBerry Torch 9800
My Carrier: MTN Nigeria

Re: Generate value using MD5 hash.

Kudos It works fine... Is there a way i can restrict the results to alphanumeric characters only? Instead of symbols?