Java
import java.nio.charset.Charset;import java.security.MessageDigest;import java.util.ArrayList;import java.util.List;public class DemoSHA256 { public static void main(String[] args) throws Exception { Listll = new ArrayList () { { this.add("测试者310112197801012344"); }}; for (String sSrc : ll) { System.out.println(String.format("%s\t%s", sSrc, getSHA256(sSrc))); } } private static String getSHA256(String input) throws Exception { MessageDigest md = MessageDigest.getInstance("SHA-256"); md.update(input.getBytes(Charset.forName("UTF-8"))); byte byteData[] = md.digest(); StringBuilder sb = new StringBuilder(); for (byte aByteData : byteData) { sb.append(Integer.toString((aByteData & 0xff) + 0x100, 16).substring(1)); } return sb.toString(); }}
Python
import hashlib def sha256(input): hash_object = hashlib.sha256(input) hex_dig = hash_object.hexdigest() return hex_dig
PHP
hash('sha256', input);