cryptoCoreHsalsa20 static method

Uint8List cryptoCoreHsalsa20(
  1. Uint8List i,
  2. Uint8List k,
  3. Uint8List? c
)

Implementation

static Uint8List cryptoCoreHsalsa20(Uint8List i, Uint8List k, Uint8List? c) {
  RangeError.checkValueInInterval(i.length, cryptoCoreHsalsa20Inputbytes,
      cryptoCoreHsalsa20Inputbytes, 'i', 'Invalid length');
  RangeError.checkValueInInterval(k.length, cryptoCoreHsalsa20Keybytes,
      cryptoCoreHsalsa20Keybytes, 'k', 'Invalid length');
  if (c != null) {
    RangeError.checkValueInInterval(c.length, cryptoCoreHsalsa20Constbytes,
        cryptoCoreHsalsa20Constbytes, 'c', 'Invalid length');
  }
  final _out = calloc<Uint8>(cryptoCoreHsalsa20Outputbytes);
  final _in = i.toPointer();
  final _k = k.toPointer();
  final _c = c?.toPointer() ?? nullptr;

  try {
    _cryptoCore
        .crypto_core_hsalsa20(_out, _in, _k, _c)
        .mustSucceed('crypto_core_hsalsa20');
    return _out.toList(cryptoCoreHsalsa20Outputbytes);
  } finally {
    calloc.free(_out);
    calloc.free(_in);
    calloc.free(_k);
    if (_c != nullptr) {
      calloc.free(_c);
    }
  }
}