EncryptionArtefacts.fromSerialized constructor

EncryptionArtefacts.fromSerialized(
  1. String serialized
)

Create new encryption artefacts from Cryppo's artifact serialized/encrypted format (this is the third part of the serialized string)

Implementation

EncryptionArtefacts.fromSerialized(String serialized) {
  final artefactBytes = base64Url.decode(serialized);
  final versionByte = artefactBytes.sublist(0, 1);
  this.version = utf8.decode(versionByte);
  final decoded =
      BSON().deserialize(BsonBinary.from(artefactBytes.sublist(1)));
  this.salt = decoded['iv'].byteList;
  this.authTag = decoded['at'].byteList;
  this.authData = utf8.encode(decoded['ad']);
}