BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 06-11-2007, 02:53 PM   #1 (permalink)
Talking BlackBerry Encyclopedia
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default md5 hashing

Please Login to Remove!

Hey all,
I'm attempting to md5 hash a value and am running into problems. What I thought would work
MD5Digest digest = new MD5Digest();
            FWApp.log("digest: "+new String(digest.getDigest()));
yields something like qiD2ž*‰q¹Œzi\– which is not like any md5 hash I've ever seen. if I try the version suggested in the javadocs (below), I get basically the same thing. Has anyone done a successfull md5 (or other hash) and knows how to get the proper resultant?

javadoc ver:
 // sampleMD5Digest        
    private static int sampleMD5Digest( byte[] plainText, byte[] digestData ) throws CryptoException, IOException
        // Create an instance of the digest algorithm
        MD5Digest digest = new MD5Digest();
        // Create the digest output stream for easy use
        DigestOutputStream digestStream = new DigestOutputStream( digest, null );
        // Write the text to the stream
        digestStream.write( plainText );
        // Copy the digest data to the digestData byte array and
        // return the length
        digest.getDigest( digestData, 0 );
        return digest.getDigestLength();
Old 08-22-2007, 07:35 PM   #2 (permalink)
BlackBerry Extraordinaire
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts

The digest is 128 bits stored in a byte array 16 long. Most MD5 digests I've seen have been Base64 encoded. Have a look at Base64OutputStream and ByteArrayOutputStream.
Old 08-22-2007, 11:05 PM   #3 (permalink)
Thumbs Must Hurt
Rose's Avatar
Join Date: Nov 2006
Location: India
Model: 9700
OS: Windows 7
Carrier: Airtel
Posts: 121
Post Thanks: 0
Thanked 0 Times in 0 Posts

Try to get the digest data which is normally a byte array of MD5 hash.

Convert the byte array in to a string.

Compare both the strings..

else do a base64 Conversion as suggested..
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

SIEMENS 14CUD32BG Magnetic Motor Starter
SIEMENS 14CUD32BG Magnetic Motor Starter pictureSIEMENS 5SJ41108HG41 Circuit Breaker
SIEMENS 5SJ41108HG41 Circuit Breaker pictureSIEMENS 5SJ42117HG41 Circuit Breaker
SIEMENS 5SJ42117HG41 Circuit Breaker pictureSIEMENS 5SJ43158HG42 Circuit Breaker
SIEMENS 5SJ43158HG42 Circuit Breaker pictureSIEMENS GNF322R Safety Switch,NEMA 3R,3W,3P,8x11x18.5
SIEMENS GNF322R Safety Switch,NEMA 3R,3W,3P,8x11x18.5 picture

Copyright © 2004-2016
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.