java版hmac-md5 with hex
程序员文章站
2022-06-07 21:20:44
...
java hmac-md5
新博客地址
import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.codec.binary.Hex; public class EncodeTest { public static void main(String[] args) throws Exception { SecretKey key = new SecretKeySpec("secretkey".getBytes(), "HmacMD5"); Mac mac = Mac.getInstance(key.getAlgorithm()); mac.init(key); byte[] code = mac.doFinal("the message need sign".getBytes()); System.out.println(Hex.encodeHex(code)); } }
新博客地址
上一篇: 【PTA团队天梯赛】L2 7-98 海盗分赃 (25分)
下一篇: 配置MAVEN的NEXUS私服