com.litongjava.tio.utils.encoder.Sha1Utils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tio-utils Show documentation
Show all versions of tio-utils Show documentation
t-io is a aio framework for java
package com.litongjava.tio.utils.encoder;
import java.nio.charset.Charset;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Sha1Utils {
private final static String ALGORITHM = "SHA-1";
public static byte[] SHA1(byte[] decript) {
try {
MessageDigest digest = java.security.MessageDigest.getInstance(ALGORITHM);
digest.update(decript);
return digest.digest();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
public static byte[] SHA1(String decript) {
return SHA1(decript.getBytes());
}
public static String SHA1(String decript, Charset encoding) {
byte[] array = SHA1(decript);
return new String(array, encoding);
}
}