定义所需要用到的变量
private static final String ENCRYPTION_KEY = "HI, I'M UPYOU.";
private static final String CHARSET_NAME = "UTF-8";
private static final String ALGORITHM_NAME = "DES";
private static Key key;
将ENCRYPTION_KEY
作为一个加密密钥,将ENCRYPTION_KEY
转成Key
类型。
static {
try {
// 生成 ALGORITHM_NAME 算法对象
KeyGenerator edsAlgorithmInstance = KeyGenerator.getInstance(ALGORITHM_NAME);
// 使用SHA1安全策略
SecureRandom sha1PRNG = SecureRandom.getInstance("SHA1PRNG"