/** * AES-128-CBC encryption. The IV is returned as the first 16 bytes * of the cipher text. * * @param key * @param plain * * @return the IV and cipher text * * @throws GeneralSecurityException */ public static byte[] aes128cbcEncrypt(byte[] key, byte[] plain) throws GeneralSecurityException { Cipher cipher = Cipher.getInstance(CIPHER_TYPE); byte iv[] = getRandomBytes(cipher.getBlockSize()); return concat(iv, aes128cbcEncryptWithIV(key, iv, plain)); }
/** * AES-128-CBC encryption. The IV is returned as the first 16 bytes * of the cipher text. * * @param key * @param plain * * @return the IV and cipher text * * @throws GeneralSecurityException */ public static byte[] aes128cbcEncrypt(byte[] key, byte[] plain) throws GeneralSecurityException { Cipher cipher = Cipher.getInstance(CIPHER_TYPE); byte iv[] = getRandomBytes(cipher.getBlockSize()); return Bytes.concat(iv, aes128cbcEncryptWithIV(key, iv, plain)); }
/** * AES-128-CBC encryption. The IV is returned as the first 16 bytes * of the cipher text. * * @param key * @param plain * * @return the IV and cipher text * * @throws GeneralSecurityException */ public static byte[] aes128cbcEncrypt(byte[] key, byte[] plain) throws GeneralSecurityException { Cipher cipher = Cipher.getInstance(CIPHER_TYPE); byte iv[] = getRandomBytes(cipher.getBlockSize()); return Bytes.concat(iv, aes128cbcEncryptWithIV(key, iv, plain)); }
/** * AES-128-CBC encryption. The IV is returned as the first 16 bytes * of the cipher text. * * @param key * @param plain * * @return the IV and cipher text * * @throws GeneralSecurityException */ public static byte[] aes128cbcEncrypt(byte[] key, byte[] plain) throws GeneralSecurityException { Cipher cipher = Cipher.getInstance(CIPHER_TYPE); byte iv[] = getRandomBytes(cipher.getBlockSize()); return Bytes.concat(iv, aes128cbcEncryptWithIV(key, iv, plain)); }
/** * AES-128-CBC encryption. The IV is returned as the first 16 bytes * of the cipher text. * * @param key * @param plain * * @return the IV and cipher text * * @throws GeneralSecurityException */ public static byte[] aes128cbcEncrypt(byte[] key, byte[] plain) throws GeneralSecurityException { Cipher cipher = Cipher.getInstance(CIPHER_TYPE); byte iv[] = getRandomBytes(cipher.getBlockSize()); return concat(iv, aes128cbcEncryptWithIV(key, iv, plain)); }