Here you can find the source of sha1(String input, String encoding)
Parameter | Description |
---|---|
input | a parameter |
encoding | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static byte[] sha1(String input, String encoding) throws Exception
//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)); } }