Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class Aes

  1. Object
  2. 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);

Methods

public static byte[] cbcEncrypt(byte[] key, byte[] iv, byte[] data)Encrypts data, a whole number of blocks, with key (16, 24 or 32 bytes) chained from the 16 byte iv.
public static byte[] cbcDecrypt(byte[] key, byte[] iv, byte[] data)Decrypts data, a whole number of blocks, with key (16, 24 or 32 bytes) chained from the 16 byte iv.

Inherited methods

Method details

cbcEncrypt

public static byte[] cbcEncrypt(byte[] key, byte[] iv, byte[] data)
Encrypts data, a whole number of blocks, with key (16, 24 or 32 bytes) chained from the 16 byte iv.

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, with key (16, 24 or 32 bytes) chained from the 16 byte iv. 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