encode method
Encrypts plaintext with a key derived from passPhrase and returns
the envelope as a JSON string.
Implementation
Future<String> encode(
String plaintext,
String passPhrase, {
HashingAlgoType hashingAlgoType = HashingAlgoType.argon2id,
HashParams? hashParams,
}) async {
final aes = await _encryptorForPassphrase(passPhrase, hashingAlgoType,
hashParams: hashParams);
final iv = InitialisationVector.random(16);
return jsonEncode({
'content': aes.encrypt(plaintext, iv: iv),
'iv': base64Encode(iv.ivBytes),
'hashingAlgoType': hashingAlgoType.name,
});
}