Java SHA1 sha1(String input, String encoding)

Here you can find the source of sha1(String input, String encoding)

Description

sha

License

Open Source License

Parameter

Parameter Description
input a parameter
encoding a parameter

Exception

Parameter Description
Exception an exception

Declaration

public static byte[] sha1(String input, String encoding) throws Exception 

Method Source Code


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

public class Main {
    /**/* w  ww .  ja  va 2s  . c o m*/
     * 
     * 
     * @param input
     * @param encoding
     * @return
     * @throws Exception
     */
    public static byte[] sha1(String input, String encoding) throws Exception {
        return digest(input, "sha-1", encoding);
    }

    private static byte[] digest(String input, String algorithm, String encoding) throws Exception {
        MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
        return messageDigest.digest(input.getBytes(encoding));
    }
}

Related

  1. sha1(String input)
  2. sha1(String input)
  3. sha1(String input)
  4. sha1(String input)
  5. sha1(String input)
  6. sha1(String message)
  7. sha1(String param)
  8. sha1(String raw)
  9. sha1(String s)