Here you can find the source of sha256(String str)
public static String sha256(String str)
//package com.java2s; //License from project: Apache License import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String sha256(String str) { String SHA = ""; try {// w ww .j a va 2s . com MessageDigest sh = MessageDigest.getInstance("SHA-256"); sh.update(str.getBytes()); byte byteData[] = sh.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < byteData.length; i++) { sb.append(Integer .toString((byteData[i] & 0xff) + 0x100, 16) .substring(1)); } SHA = sb.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); SHA = null; } return SHA; } }