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
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 atIt 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 atJava 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
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