Java SHA256 getSHA256(String input)

Here you can find the source of getSHA256(String input)

Description

get SHA

License

Open Source License

Declaration

public static String getSHA256(String input) 

Method Source Code


//package com.java2s;
/*//from w  w  w  .jav a 2 s.  c  o m
 * SigmaX 1.0.0b1 Source Code
 * Copyright (c) 2016 Curecoin Developers
 * Distributed under MIT License
 * Requires Apache Commons Library
 * Supports Java 1.7+
 */

import java.io.UnsupportedEncodingException;

import java.security.MessageDigest;

import javax.xml.bind.DatatypeConverter;

public class Main {
    private static MessageDigest md;

    public static String getSHA256(String input) {
        try {
            return DatatypeConverter.printHexBinary(md.digest(input.getBytes("UTF-8")));
        } catch (UnsupportedEncodingException e) {
            System.err.println("[CRITICAL] UTF-8 ENCODING NOT SUPPORTED. EXITING.");
            System.exit(-1);
            return "ERROR"; // Make compiler happy.
        }
    }
}

Related

  1. digestSHA256(byte[] input)
  2. digestSha256(String plain)
  3. digestSha256(String value)
  4. sha256()
  5. sha256(byte[] bytes)
  6. sha256(byte[] data)
  7. sha256(byte[] data)