Class Aes
AES (FIPS 197) in CBC mode over whole 16 byte blocks, with no padding: the building block of formats that define their own padding or key handling, such as the PDF security handler. Runs on the client and on the backend.
The installed CryptoEngine does the work where the platform has a native
cipher (the client ports and the backend); elsewhere, the JavaScript port
among them, a portable Java implementation produces the same bytes. For
authenticated encryption of application data on the client use Cipher instead.
byte[] key = new byte[16];
byte[] iv = new byte[16];
byte[] sealed = Aes.cbcEncrypt(key, iv, new byte[32]);
byte[] plain = Aes.cbcDecrypt(key, iv, sealed);
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]cbcDecrypt(byte[] key, byte[] iv, byte[] data) Decryptsdata, a whole number of blocks, withkey(16, 24 or 32 bytes) chained from the 16 byteiv.static byte[]cbcEncrypt(byte[] key, byte[] iv, byte[] data) Encryptsdata, a whole number of blocks, withkey(16, 24 or 32 bytes) chained from the 16 byteiv.
-
Method Details
-
cbcEncrypt
public static byte[] cbcEncrypt(byte[] key, byte[] iv, byte[] data) Encrypts
data, a whole number of blocks, withkey(16, 24 or 32 bytes) chained from the 16 byteiv.Throws
IllegalArgumentException: for a key, IV or data of the wrong length
-
cbcDecrypt
public static byte[] cbcDecrypt(byte[] key, byte[] iv, byte[] data) Decrypts
data, a whole number of blocks, withkey(16, 24 or 32 bytes) chained from the 16 byteiv. Padding, if the format has any, is left for the caller to remove.Throws
IllegalArgumentException: for a key, IV or data of the wrong length
-