decryptBytes abstract method
Decrypt data
with this AesCbcSecretKey using AES in Cipher Block
Chaining mode, as specified in NIST SP800-38A.
To decrypt data
the same initalization vector iv
as was used for
encryption must be specified. The iv
must always be 16 bytes.
See encryptBytes for further discussion of the initialization vector.
The encrypted data
is always assumed to be padded in PKCS#7 mode,
as described in
RFC 2315 Section 10.3 step 2.
This padding is stripped from the decrypted return value.
The encryptBytes and encryptStream methods always apply this padding.
Example
import 'dart:convert' show utf8;
import 'dart:typed_data' show Uint8List;
import 'package:webcrypto/webcrypto.dart';
// Generate a new random AES-CBC secret key for AES-256.
final k = await AesCbcSecretKey.generate(256);
// Use a unique IV for each message.
final iv = Uint8List(16);
fillRandomBytes(iv);
// Encrypt a message
final c = await k.encryptBytes(utf8.encode('hello world'), iv);
// Decrypt message (requires the same iv)
print(utf8.decode(await k.decryptBytes(c, iv))); // hello world
Implementation
Future<Uint8List> decryptBytes(List<int> data, List<int> iv);