我有这个简单的代码,我在互联网上找到..我正在学习这个加密/解密的东西..这段代码似乎工作正常,但我不明白的东西......为什么在"c.doFinal()之后"(用于使用AES-256加密/解密)这个人使用BASE64编码/解码该加密值?仅使用AES还不够?
`private static final String ALGO = "AES";
private static final byte[] keyValue =
new byte[] { 'T', 'h', 'e', 'B', 'e', 's', 't', 'S', 'e', 'c', 'r','e', 't', 'K', 'e', 'y' };
public static String encrypt(String Data) throws Exception {
Key key = generateKey();
Cipher c = Cipher.getInstance("AES");
c.init(Cipher.ENCRYPT_MODE, key);
byte[] encVal = c.doFinal(Data.getBytes());
String encryptedValue = new BASE64Encoder().encode(encVal);
return encryptedValue;
}
public static String decrypt(String encryptedData) throws Exception {
Key key = generateKey();
Cipher c = Cipher.getInstance(ALGO);
c.init(Cipher.DECRYPT_MODE, …Run Code Online (Sandbox Code Playgroud)