me.xethh.libs.toolkits.encryption.Sha2Hash Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Library of common used tools - major focus on common tools
The newest version!
package me.xethh.libs.toolkits.encryption;
import org.bouncycastle.util.encoders.Hex;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
public class Sha2Hash {
public static String SHA2 = "SHA-512";
public static byte[] hashBytes(byte[] bytes){
return hash(bytes);
}
public static String hashBytes64(byte[] bytes){
return hashBase64(bytes);
}
public static String hashBytesHex(byte[] bytes){
return hashHex(bytes);
}
public static MessageDigest digest(){
try {
return MessageDigest.getInstance(SHA2);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage(), e);
}
}
public static byte[] hash(byte[]... bytes){
MessageDigest digest = digest();
for(int i=0;i