涉及变量: // 加密密码:key==>springblade //content==>需要加密的内容
//password==>加密密码
二:AES加密
public static String encrypt(String str) {
return HexKit.binary2Hex(encryptByte(str, key));
}
private static byte[] encryptByte(String content, String password) {
try {
KeyGenerator kgen = KeyGenerator.getInstance("AES");
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
secureRandom.setSeed(password.getBytes());
kgen.init(128, secureRandom);
SecretKey secretKey = kgen.generateKey();
byte[] enCodeFormat = secretKey.getEncoded();
SecretKeySpec key = new SecretKeySpec(enCodeFormat, "AES");
Cipher cipher = Cipher.getInstance("AES");// 创建密码器
byte[] byteContent = con