serialize method

String serialize()

Convert artefacts to a format that can be used in Cryppo's encryption serialization format

Implementation

String serialize() {
  final versionByte = utf8.encode('A');
  final bsonPayload = BSON().serialize({
    'iv': BsonBinary.from(salt),
    'at': BsonBinary.from(authTag),
    'ad': utf8.decode(authData)
  });

  return base64Url.encode([...versionByte, ...bsonPayload.byteList]);
}