Here you can find the source of getHash(String var)
public static String getHash(String var)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String getHash(String var) { try {//from w ww . j a v a2 s . com MessageDigest md = MessageDigest.getInstance("SHA-256"); byte[] varbytes = var.getBytes("UTF-8"); byte[] result = md.digest(varbytes); StringBuffer sb = new StringBuffer(); for (int i = 0; i < result.length; ++i) { sb.append(Integer.toHexString(0xFF & result[i])); } String hash = sb.toString(); return hash; } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; } }