crypto_secretbox static method

Uint8List crypto_secretbox(
  1. Uint8List c,
  2. Uint8List m,
  3. int d,
  4. Uint8List n,
  5. Uint8List k,
)

Implementation

static Uint8List crypto_secretbox(
    Uint8List c, Uint8List m, final int d, Uint8List n, Uint8List k) {
  if (d < 32) {
    throw 'SecretBox is invalid';
  }

  crypto_stream_xor(c, 0, m, 0, d, n, k);
  _crypto_onetimeauth(c, 16, c, 32, d - 32, c);

  // FIXME: Check in tweetnacl where these 16 bytes disappear?
  //for (i = 0; i < 16; i++) c[i] = 0;
  return c.sublist(16);
}