java and javascript creating md5 hash


Javasript example:
var md5_inputstr = "test"; var hashmd5 = hex_md5(md5_inputstr) console.log(hashmd5)   
// 098f6bcd4621d373cade4e832627b4f6
->
http://pajhome.org.uk/crypt/md5/ Java example:

private void main(){ String strHash = getMD5Str("test") System.out.println(strHash); // 098f6bcd4621d373cade4e832627b4f6 } private String getMD5Str(String chechSum) { String hashedPass = null; try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(chechSum.getBytes(), 0, chechSum.length()); hashedPass = new BigInteger(1, messageDigest.digest()).toString(16); if (hashedPass.length() < 32) { hashedPass = "0" + hashedPass; } } catch (Exception e) { System.out.println("failed to create md5"); System.out.println(e.getMessage()); } return hashedPass; }
-->
http://www.mkyong.com/java/java-md5-hashing-example/
:] 

Comments

Popular Posts