Support HMAC algorithm functions #470
This commit is contained in:
@@ -189,27 +189,27 @@ public class CodecFunc implements IFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String hmacMd5(String secretKey, String data) {
|
public String hmacMd5(String data, String secretKey) {
|
||||||
return new HmacUtils(HmacAlgorithms.HMAC_MD5, secretKey).hmacHex(data);
|
return new HmacUtils(HmacAlgorithms.HMAC_MD5, secretKey).hmacHex(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String hmacSha1(String secretKey, String data) {
|
public String hmacSha1(String data, String secretKey) {
|
||||||
return new HmacUtils(HmacAlgorithms.HMAC_SHA_1, secretKey).hmacHex(data);
|
return new HmacUtils(HmacAlgorithms.HMAC_SHA_1, secretKey).hmacHex(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String hmacSha224(String secretKey, String data) {
|
public String hmacSha224(String data, String secretKey) {
|
||||||
return new HmacUtils(HmacAlgorithms.HMAC_SHA_224, secretKey).hmacHex(data);
|
return new HmacUtils(HmacAlgorithms.HMAC_SHA_224, secretKey).hmacHex(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String hmacSha256(String secretKey, String data) {
|
public String hmacSha256(String data, String secretKey) {
|
||||||
return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, secretKey).hmacHex(data);
|
return new HmacUtils(HmacAlgorithms.HMAC_SHA_256, secretKey).hmacHex(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String hmacSha384(String secretKey, String data) {
|
public String hmacSha384(String data, String secretKey) {
|
||||||
return new HmacUtils(HmacAlgorithms.HMAC_SHA_384, secretKey).hmacHex(data);
|
return new HmacUtils(HmacAlgorithms.HMAC_SHA_384, secretKey).hmacHex(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String hmacSha512(String secretKey, String data) {
|
public String hmacSha512(String data, String secretKey) {
|
||||||
return new HmacUtils(HmacAlgorithms.HMAC_SHA_512, secretKey).hmacHex(data);
|
return new HmacUtils(HmacAlgorithms.HMAC_SHA_512, secretKey).hmacHex(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class CodecFuncTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testHmacSha256() {
|
void testHmacSha256() {
|
||||||
String funcExpression = "fn.codec.hmacSha256(\"635e8562b968bc05bb80cacf124ebd53285280ee6845df0000faa33acafc38f0\", \"12345678123456781234567812345678\")";
|
String funcExpression = "fn.codec.hmacSha256(\"12345678123456781234567812345678\", \"635e8562b968bc05bb80cacf124ebd53285280ee6845df0000faa33acafc38f0\")";
|
||||||
Object result = FuncExecutor.getInstance().exec(null, funcExpression);
|
Object result = FuncExecutor.getInstance().exec(null, funcExpression);
|
||||||
assertEquals("c61be0237ec186df1c5f51425e607093b260a76e5de43a62cb3e821103303990", result.toString());
|
assertEquals("c61be0237ec186df1c5f51425e607093b260a76e5de43a62cb3e821103303990", result.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user