Here you can find the source of sha256(final String aString)
public static String sha256(final String aString)
//package com.java2s; //License from project: Apache License import android.text.TextUtils; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String sha256(final String aString) { String result = null;/*from ww w . j a va 2 s . co m*/ if (TextUtils.isEmpty(aString)) return result; MessageDigest md; StringBuffer hexString = new StringBuffer(); try { md = MessageDigest.getInstance("SHA-256"); md.reset(); md.update(aString.getBytes()); byte[] messageDigest = md.digest(); for (int i = 0; i < messageDigest.length; i++) { String hex = Integer.toHexString(0xff & messageDigest[i]); if (hex.length() == 1) hexString.append('0'); hexString.append(hex); } result = hexString.toString(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return result; } }