All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.xethh.libs.toolkits.encryption.Sha2Hash Maven / Gradle / Ivy

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy