gistfile1.txt import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;public class SHA256 { public static String encrypt(String strSrc) { MessageDigest md; String strDes; String encName = "SHA-256"; byte[] bt = strS
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class SHA256 { public static String encrypt(String strSrc) { MessageDigest md; String strDes; String encName = "SHA-256"; byte[] bt = strSrc.getBytes(); try { md = MessageDigest.getInstance(encName); md.update(bt); strDes = bytes2Hex(md.digest()); } catch (NoSuchAlgorithmException e) { return null; } return strDes; } private static String bytes2Hex(byte[] bts) { StringBuilder des = new StringBuilder(); String tmp; for (byte bt : bts) { tmp = (Integer.toHexString(bt & 0xFF)); if (tmp.length() == 1) { des.append("0"); } des.append(tmp); } return des.toString(); } }