zoukankan      html  css  js  c++  java
  • HmacSha1加密-java

     1 package com.test;
     2 
     3 import javax.crypto.Mac;
     4 import javax.crypto.spec.SecretKeySpec;
     5 import org.apache.commons.codec.binary.Base64;
     6 
     7 
     8 public class HmacSha1Test {
     9     private static final String APP_SECRET = "your_key";
    10     public static void main(String[] args) throws Exception {
    11         SecretKeySpec keySpec = new SecretKeySpec(
    12                 APP_SECRET.getBytes("UTF-8"),
    13                 "HmacSHA1");
    14         Mac mac = Mac.getInstance("HmacSHA1");
    15         mac.init(keySpec);
    16         byte[] result = mac.doFinal("123456".getBytes());
    17         String resultStr = Base64.encodeBase64String(result);
    18     }
    19 }
  • 相关阅读:
    场景调研
    12.8
    12.7
    12.6
    12.5
    12.4
    12.3
    重启oracle数据库的操作方法
    oracle创建dblink方法
    SQL*Loader 详解
  • 原文地址:https://www.cnblogs.com/phoenix-smile/p/5082716.html
Copyright © 2011-2022 走看看