Hu tool加密

package com.aaa.utils;

import cn.hutool.core.codec.Base64;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.AES;

import java.util.Date;

/**
 * @author XDL
 * @version 1.0
 * @program GameShop
 * @date 2022/07/05/0005  19:18:22
 */
public class KeyUtil {
   //固定密钥
   private static final String BASE64_SECRET = "aEsva0zDHECg47P8SuPzmw==";

    /**
     * aes用来加密解密的byte[]
     */
    private final static byte[] SECRET_BYTES = Base64.decode(BASE64_SECRET);

    /**
     * 根据这个秘钥得到一个aes对象
     */
    private final static AES aes = SecureUtil.aes(SECRET_BYTES);

    public static String jiaMi(String str){
      //加密
      String encrypt = aes.encryptHex(str);
      return encrypt;
  }

    public static void main(String[] args) {
        System.out.println(jiaMi("111"));
        Date date = new Date();
        System.out.println(date);
    }
}

你可能感兴趣的:(java,大数据,开发语言)