Java SHA1 SHA1(String str)

Here you can find the source of SHA1(String str)

Description

SHA

License

GNU General Public License

Declaration

@SuppressWarnings("resource")
    public static String SHA1(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException 

Method Source Code


//package com.java2s;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Formatter;

public class Main {
    @SuppressWarnings("resource")
    public static String SHA1(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest mDigest = MessageDigest.getInstance("SHA-1");
        mDigest.reset();/*w  ww .  j  a va2 s .c  o  m*/
        mDigest.update(str.getBytes("UTF-8"));
        Formatter f = new Formatter();
        for (byte b : mDigest.digest())
            f.format("%02x", b);
        return f.toString();
    }
}

Related

  1. sha1(String str)
  2. sha1(String str)
  3. sha1(String str)
  4. sha1(String str)
  5. sha1(String str)
  6. sha1(String str)
  7. sha1(String str)
  8. SHA1(String str)
  9. sha1(String string)