Java SHA256 sha256(String string)

Here you can find the source of sha256(String string)

Description

sha

License

Open Source License

Declaration

public static byte[] sha256(String string) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static byte[] sha256(String string) {

        MessageDigest digest;//from   w w  w . ja  v a 2s. c  om

        try {

            digest = MessageDigest.getInstance("SHA-256");
        } catch (NoSuchAlgorithmException ex) {

            throw new RuntimeException(ex.getMessage(), ex);
        }

        return digest.digest(string.getBytes(StandardCharsets.UTF_8));
    }
}

Related

  1. sha256(String s)
  2. sha256(String src)
  3. sha256(String srcStr)
  4. sha256(String str)
  5. sha256(String str)
  6. sha256(String string, String secret)
  7. sha256(String strSrc)
  8. SHA256(String text)
  9. SHA256(String text)