zoukankan      html  css  js  c++  java
  • HMAC算法加密

     1 /**
     2      * HMAC算法加密
     3      * @param message 待加密信息
     4      * @param key 密钥
     5      * @return 
     6      */
     7     public static String HmacSHA256(byte[] message, byte[] key){
     8         long begin = System.currentTimeMillis();
     9         try {
    10             Mac hmacSha256Mac = Mac.getInstance("HMACSha256");
    11             SecretKeySpec secretKey = new SecretKeySpec(key, "HMACSha256");
    12             hmacSha256Mac.init(secretKey);
    13             byte[] result = hmacSha256Mac.doFinal(message);
    14             long end = System.currentTimeMillis();
    15             return Base64.encodeBase64String(result);
    16         } catch (Exception e) {
    17             e.printStackTrace();
    18             return "";
    19         }
    20     }
  • 相关阅读:
    导出 IIS 站点及配置
    redis
    mongo常用
    mongo分片集群
    mysql常用
    elk安装
    Oracle数据库迁移文档
    笔记
    ping 。sh
    光衰报警
  • 原文地址:https://www.cnblogs.com/redhat0019/p/8034036.html
Copyright © 2011-2022 走看看