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

com.codingapi.springboot.framework.crypto.HmacSHA256 Maven / Gradle / Ivy

The newest version!
package com.codingapi.springboot.framework.crypto;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class HmacSHA256 {

    public static byte[] sha256(byte[] message,byte[] secret) throws NoSuchAlgorithmException, InvalidKeyException {
        Mac sha256_HMAC = Mac.getInstance("HmacSha256");
        SecretKeySpec secretKey = new SecretKeySpec(secret,"HmacSha256");
        sha256_HMAC.init(secretKey);
        return sha256_HMAC.doFinal(message);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy