Java SHA256 SHA256(String text)

Here you can find the source of SHA256(String text)

Description

SHA

License

Mozilla Public License

Declaration

public static byte[] SHA256(String text) 

Method Source Code

//package com.java2s;
//License from project: Mozilla Public License 

import java.io.UnsupportedEncodingException;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static byte[] SHA256(String text) {
        try {/*from  w ww .  j  a v  a 2 s  . c o  m*/
            MessageDigest md;
            md = MessageDigest.getInstance("SHA-256");
            md.update(text.getBytes("UTF-8"), 0, text.length());
            return md.digest();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. sha256(String str)
  2. sha256(String string)
  3. sha256(String string, String secret)
  4. sha256(String strSrc)
  5. SHA256(String text)
  6. sha256(String text)
  7. SHA256(String texto)
  8. SHA256Binary(String toHash)
  9. SHA256byte(String input)