bricks-common/src/main/java/org/eurekaka/bricks/common/util/Utils.java
public static Mac initialHMac(String secret, String algo) {
        Mac sha_HMAC;
        try {
            sha_HMAC = Mac.getInstance(algo);
            SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), algo);
            sha_HMAC.init(secret_key);
        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
            throw new RuntimeException("failed to create hmac " + algo, e);
        }
        return sha_HMAC;
    }
/**
     * initial hmac encryption instance
     * @param secret secret key
     * @param algo HmacSHA256, HmacSHA512
     * @return hmac instance
     */
initial hmac encryption instance
@param secret secret key
@param algo HmacSHA256, HmacSHA512
@return hmac instance
initial hmac encryption instance @param secret secret key @param algo HmacSHA256 HmacSHA512 @return hmac instance
public static Mac initialHMac(String secret, String algo) {
        Mac sha_HMAC;
        try {
            sha_HMAC = Mac.getInstance(algo);
            SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), algo);
            sha_HMAC.init(secret_key);
        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
            throw new RuntimeException("failed to create hmac " + algo, e);
        }
        return sha_HMAC;
    }
public static Mac initialHMac ( String secret , String algo ) { Mac sha_HMAC ; try { sha_HMAC = Mac . getInstance ( algo ) ; SecretKeySpec secret_key = new SecretKeySpec ( secret . getBytes ( ) , algo ) ; sha_HMAC . init ( secret_key ) ; } catch ( NoSuchAlgorithmException | InvalidKeyException e ) { throw new RuntimeException ( "failed to create hmac " + algo , e ) ; } return sha_HMAC ; }
initial hmac encryption instance
 @param secret secret key
 @param algo HmacSHA256, HmacSHA512
 @return hmac instance
initial hmac encryption instance @param secret secret key @param algo HmacSHA256 HmacSHA512 @return hmac instance