package core.framework.api.crypto;
import core.framework.api.util.Strings;
import org.junit.Assert;
import org.junit.Test;
/**
* @author neo
*/
public class HMACTest {
@Test
public void digestByMD5() {
HMAC hmac = new HMAC(Strings.bytes("4VPDEtyUE"), HMAC.Hash.MD5);
byte[] bytes = hmac.digest(Strings.bytes("hello"));
Assert.assertNotNull(bytes);
}
@Test
public void digestBySHA512() {
HMAC hmac = new HMAC(Strings.bytes("4VPDEtyUE"), HMAC.Hash.SHA512);
byte[] bytes = hmac.digest(Strings.bytes("hello"));
Assert.assertNotNull(bytes);
}
@Test
public void generateKey() {
byte[] key = HMAC.generateKey(HMAC.Hash.SHA512);
HMAC hmac = new HMAC(key, HMAC.Hash.SHA512);
byte[] bytes = hmac.digest(Strings.bytes("hello"));
Assert.assertNotNull(bytes);
}
}