JAVA实现AES加密
java实现AES加密,直接上代码:
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
/**
*这个示例程序展示了如何用Java实现AES加密和解密。请注意
*密钥和加密的文本是不可读的二进制文件,因此在下面的程序中,我们
*以基础字节的十六进制格式显示。
*/
public class AESEncryption {
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
/**
* 1. Generate a plain text for encryption 2. Get a secret key (printed in hexadecimal form). In actual use this must by encrypted and kept safe. The same key is required for decryption.
*/
public static void main(String[] args) throws Exception {
String plainText = &#