Java SHA1 sha1(String str)

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

Description

sha

License

Open Source License

Declaration

public static String sha1(String str) 

Method Source Code


//package com.java2s;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Main {
    public static String sha1(String str) {
        try {// www  . ja va 2 s.com
            StringBuffer sb = new StringBuffer();
            MessageDigest md = MessageDigest.getInstance("sha1");
            md.update(str.getBytes());
            byte[] msg = md.digest();
            for (byte b : msg) {
                sb.append(String.format("%02x", b));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }
}

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 string)
  9. sha1(String string)