Base64 of SHA1 for J2ME

The motivation for this implementation was Java enabled cellphones with tight memory requirements.  Russell Beattie ported this code to Java, I then inlined everything that was called once to reduce the footprint.

J2SE implementations can use the builtin java.security classes.  demo


You can honestly take my name out of that code now - it has little to do with anything I contributed, really. Adding types to someone else's script and then giving it to you to clean up and make work does not equal a contribution. :-)

Nice job Sam! Now if I can just get the freakin app to work.

-Russ

Posted by Russ at

Sam Ruby: Base64 of SHA1 for J2ME

Sam Ruby: Base64 of SHA1 for J2ME...

Excerpt from Jonas Galvez (english/portuguese)'s Bookmarks at

I think there's a typo in the code

  result[i] = base64[(((words[word] & 0x03) << 4) |
  ((words[word+1] >> 28) & 0x1F)) & 0x3F];

should be:

  result[i] = base64[(((words[word] & 0x03) << 4) |
  ((words[word+1] >> 28) & 0x0F)) & 0x3F];

i.e the 0x1F constant should be 0x0F

Posted by John Wilson at

It is said that "Many Eyes Make All Bugs Shallow".

This indeed was in error.  Fixed.  Thanks!

In case anybody find this code handy, I've added an explicit BSD license to the source.

Posted by Sam Ruby at


Java enabled cellphones - help has arrived

Sam Ruby has come up with a little treat for Java enabled cell phone users that are plagued with limited memory....... [more]

Trackback from Lockergnome's Web Developers at

Another typo... I'm pretty sure that's not JavaScript. ;)

Posted by Matt Chaput at

Matt: thanks!  Fixed.

Posted by Sam Ruby at


Sam Ruby: Base64 of SHA1 for J2ME

SHA 1 for J2ME...

Excerpt from del.icio.us/askdon2001 at


Does not work with binary files.
I found another solution. Go and see Bouncy Castle Java lightweight implementation.
[link]

Posted by anonymous at

Add your comment












Nav Bar