2016-11-29 757 views
0

我正在使用org.apache.commons.codec.digest.HmacUtils.hmacSha1Hex(“secretkey”,“message”);hmacSha1Hex和hmacSha1之间有什么区别吗?

并在输出中获得长字符串。我试图执行org.apache.commons.codec.digest.HmacUtils.hmacSha1(“secretkey”,“message”);我试图执行org.apache.commons.codec.digest.HmacUtils.hmacSha1(“secretkey”,“message”);我试图执行org.apache.commons.codec.digest.HmacUtils.hmacSha1(“secretkey”,“message”);但面对错误

ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``String hmac_Sha1 = org.apache.commons.codec.digest.HmacUtils.hmacSha1("secretkey . . . '' : Typed variable declaration 

2016/11/29 17:09:07 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: String hmac_Sha1 = org.apache.commons.codec.

基本上我想知道输出的长度为hmacSha1Hex输出两种功能 就像HMAC SHA1哈希:像btuU9CPfMQMswNgxPIMjRkTjfks%0ff4e6a0b47baebe19c392e706fffaa13664a1df

我期待输出3D差异的长度为

回答

0

您正在寻找的答案在HmacUtils JavaDoc

  • HmacUtils.hmacSha1Hex - 是String
  • HmacUtils.hmacSha1 - 是byte[]

可以字节数组转换为类似的字符串:

String s = new String (your byte array here); 

我也建议使用JSR223 Sampler and Groovy language代替Beanshell,它符合现代Java技术并且有更好的表现。

+0

我可以从哪里获得一些链接,我可以学习groovy。我对此完全陌生。 – Nikhil

+0

在99%的案例中,有效的Java代码将是有效的Groovy代码 –

相关问题