cryptoPwhashStrAlg static method

Uint8List cryptoPwhashStrAlg(
  1. Uint8List passwd,
  2. int opslimit,
  3. int memlimit,
  4. int alg,
)

Implementation

static Uint8List cryptoPwhashStrAlg(
    Uint8List passwd, int opslimit, int memlimit, int alg) {
  RangeError.checkValueInInterval(passwd.length, cryptoPwhashPasswdMin,
      cryptoPwhashPasswdMax, 'passwd', 'Invalid length');
  RangeError.checkValueInInterval(
      opslimit, cryptoPwhashOpslimitMin, cryptoPwhashOpslimitMax, 'opslimit');
  RangeError.checkValueInInterval(
      memlimit, cryptoPwhashMemlimitMin, cryptoPwhashMemlimitMax, 'memlimit');
  RangeError.checkValueInInterval(
      alg, cryptoPwhashAlgArgon2i13, cryptoPwhashAlgArgon2id13, 'alg');

  final _out = calloc<Uint8>(cryptoPwhashStrbytes);
  final _passwd = passwd.toPointer();
  try {
    _cryptoPwhash
        .crypto_pwhash_str_alg(
            _out, _passwd, passwd.length, opslimit, memlimit, alg)
        .mustSucceed('crypto_pwhash_str_alg');
    return _out.toNullTerminatedList(cryptoPwhashStrbytes);
  } finally {
    calloc.free(_out);
    calloc.free(_passwd);
  }
}