Skip to main content

java MessageDigest

If you use MessageDigest in java to encrypt string, you wont get hash like other language does.
So you need to convert the result so that you can compare the hash result with other output that produce by diff language.
Found the function on the java net forum

private static String baToHexString(byte byteValues[]) {
byte singleChar = 0;

if (byteValues == null || byteValues.length <= 0) return null;
String entries[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
StringBuffer out = new StringBuffer(byteValues.length * 2);
for (int i = 0; i < byteValues.length; i++) {
singleChar = (byte) (byteValues[i] & 0xF0);
singleChar = (byte) (singleChar >>> 4);
// shift the bits down
singleChar = (byte) (singleChar & 0x0F);
out.append(entries[(int) singleChar]);
singleChar = (byte) (byteValues[i] & 0x0F);
out.append(entries[(int) singleChar]);
}

String rslt = new String(out);

return rslt;

}

Comments

Popular posts from this blog

Yet another online shop launch

For housewife who use to work, daily activities are dull and boring. So I've been persuade my wife to run online shop to add variation on her daily routine. Finally we decided to start selling clothing goods and knick knacks, some are airbrush paint t shirt, woman snake leather handbag are there also Since I've been working with python, I came out to use satchmo for our online shop framework After doing customizing here and there and build some payment modules, we lauch WarungRupa.com  on early January 2012 We have some ideas which are still in our thoughts and we keen to work on it Hope WarungRupa.com  can have many visitors and buyers Next to do are SEO and promotions ^_^
1 Desember 2003 Spider admin diinstall dari < http://agaipiotras.igk.pl/spider-admin.xml.gz > karena situs cvs di midgard tidak dapat diakses dan situs spider sendiri berbahasa Rusia sehingga mencari di www.google.com dengan keyword "spider-admin.xml.gz". Spider dan aegir dapat berjalan dengan baik.
wheeeww... it been a while since I do my last web bloging since the web project finally hit the road plus I've only lame ass internet connection. I've decided that this blog gonna be my personal blog that would tell you guys about my experience with opensource world and maybe a bit about my presonal things (which is almost imposible since I'm not so much open about my personal life ;) ) one other thing... yeah it would be gado-gado blog entry. That mean sometime I'll post in english and sometime in bahasa due to the limitation of my brain ;)