消息关闭
    暂无新消息!
public static String aesEncrypt(String message, String key)throws Exception {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");

byte[] keyBytes = DesUtil.getSecretKey(key, 16);

if (keyBytes == null) {
return null;
}
SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES");

cipher.init(Cipher.ENCRYPT_MODE, secretKey);

return Base64.encodeToString(cipher.doFinal(message.getBytes("UTF-8")));
}

2个回答