fromBytes static method
- Uint8List bytes
Deserializes from bytes.
Expects the first 12 bytes to be the nonce.
Throws ArgumentError if bytes is shorter than 12 bytes.
Implementation
static EncryptedData fromBytes(Uint8List bytes) {
if (bytes.length < CryptoUtils.nonceSize) {
throw ArgumentError(
'Encrypted data too short: expected at least ${CryptoUtils.nonceSize} bytes',
);
}
return EncryptedData(
nonce: bytes.sublist(0, CryptoUtils.nonceSize),
ciphertext: bytes.sublist(CryptoUtils.nonceSize),
);
}