cryptoSecretboxOpenEasy static method

Uint8List cryptoSecretboxOpenEasy(
  1. Uint8List c,
  2. Uint8List n,
  3. Uint8List k
)

Implementation

static Uint8List cryptoSecretboxOpenEasy(
    Uint8List c, Uint8List n, Uint8List k) {
  RangeError.checkValueInInterval(n.length, cryptoSecretboxNoncebytes,
      cryptoSecretboxNoncebytes, 'n', 'Invalid length');
  RangeError.checkValueInInterval(k.length, cryptoSecretboxKeybytes,
      cryptoSecretboxKeybytes, 'k', 'Invalid length');

  final _m = calloc<Uint8>(c.length - cryptoSecretboxMacbytes);
  final _c = c.toPointer();
  final _n = n.toPointer();
  final _k = k.toPointer();

  try {
    _cryptoSecretbox
        .crypto_secretbox_open_easy(_m, _c, c.length, _n, _k)
        .mustSucceed('crypto_secretbox_open_easy');
    return _m.toList(c.length - cryptoSecretboxMacbytes);
  } finally {
    calloc.free(_m);
    calloc.free(_c);
    calloc.free(_n);
    calloc.free(_k);
  }
}