Bootstrap

随机生成AES密钥base64编码

package com.xxxxxxx.controller.xxxx;

import java.security.NoSuchAlgorithmException;
import java.util.Base64;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;

public class Test {

    public static void main(String[] args) throws NoSuchAlgorithmException {
        // 直接拷贝到main运行即可生成一个Base64唯一字符串
        KeyGenerator keygen = KeyGenerator.getInstance("AES");
        SecretKey deskey = keygen.generateKey();
        System.out.println(Base64.getEncoder().encodeToString(deskey.getEncoded()));
    }
}
 

;