encryptVault function
Seal secret under password. Randomized (fresh salt + IV each call).
Implementation
VaultBlob encryptVault(String secret, String password) {
final salt = _random(16);
final iv = _random(12);
final cipher = GCMBlockCipher(AESEngine())
..init(
true,
AEADParameters(
KeyParameter(_key(password, salt)), 128, iv, Uint8List(0)));
final ct = cipher.process(Uint8List.fromList(utf8.encode(secret)));
return VaultBlob(
salt: base64.encode(salt), iv: base64.encode(iv), ct: base64.encode(ct));
}