md5 hash for password string in GWT(Encryption in GWT)


MD5 hash for password string in GWT(Encryption in GWT


add  <inherits name='com.googlecode.gwt.crypto.Crypto'/> in xml file
add gwt-crypto-2.3.0-20110518.123759-2.jar jar file in project
String getSHA1for(String text) {
SHA1Digest sd
= new SHA1Digest();
byte[] bs = text.getBytes();
sd
.update(bs, 0, bs.length);
byte[] result = new byte[20];
sd
.doFinal(result, 0);
return byteArrayToHexString(result);
}

String byteArrayToHexString(final byte[] b) {
final StringBuffer sb = new StringBuffer(b.length * 2);
for (int i = 0, len = b.length; i < len; i++) {
int v = b[i] & 0xff;
if (v < 16) sb.append('0');
sb
.append(Integer.toHexString(v));
}
return sb.toString();
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: