AES加密解密
AES
加密解密和 DES
加密解密代码一样,只需要修改加密算法就行,拷贝 ESC
代码
AesDemo.java
package com.atguigu.desaes;
import com.sun.org.apache.xml.internal.security.utils.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
/**
* DesAesDemo
* 对称加密
*/
public class AesDemo {
public static void main(String[] args) throws Exception{
// 原文
String input = "止兮666";
// 定义key
// 如果使用des进行加密,那么密钥必须是8个字节
// 如果使用的是AES加密,那么密钥必须是16个字节
String key = "1234567812345678";
// 算法
String transformation = "AES";
// 加密类型
String algorithm = "AES";
// 指定获取密钥的算法
String encryptDES = encryptDES(input, key, transformation, algorithm);
System.out.println("加密:" + encryptDES);
// String s = decrypt