Here you can find the source of SHA256(byte[] input)
public synchronized static byte[] SHA256(byte[] input)
//package com.java2s; /*/*from w w w .j a v a2s . co m*/ JJSP - Java and Javascript Server Pages Copyright (C) 2016 Global Travel Ventures Ltd This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. */ import java.nio.charset.*; import java.security.*; import java.util.*; public class Main { public static final Charset ASCII = Charset.forName("US-ASCII"); private static MessageDigest sha256; public synchronized static byte[] SHA256(byte[] input) { return sha256.digest(input); } public static String SHA256(String in) { return toHexString(SHA256(getAsciiBytes(in))); } public static String toHexString(byte[] arr) { Formatter formatter = new Formatter(); for (int i = 0; i < arr.length; i++) formatter.format("%02x", arr[i]); return formatter.toString(); } public static byte[] getAsciiBytes(String src) { if (src == null) return null; return src.getBytes(ASCII); } public static String toString(byte[] rawText) { if (rawText == null) return null; return toString(rawText, 0, rawText.length); } public static String toString(byte[] rawText, int offset, int length) { if (rawText == null) return null; return new String(rawText, offset, length, ASCII); } }