decodePayloadFromBytes static method

Payload decodePayloadFromBytes(
  1. List<int> bytes, {
  2. required int nonceLength,
  3. required int macLength,
})

Implementation

static Payload decodePayloadFromBytes(
  List<int> bytes, {
  required int nonceLength,
  required int macLength,
}) {
  final nonce = bytes.sublist(0, nonceLength);
  return PayloadLocal(
    secretBox: SecretBox.fromConcatenation(
      bytes,
      nonceLength: nonceLength,
      macLength: macLength,
    ).withNonce(Uint8List.fromList(nonce.sublist(0, nonceLength ~/ 2))),
    nonce: Mac(nonce),
    mac: Hash(bytes.sublist(bytes.length - macLength, bytes.length)),
  );
}