cryptoPwhashStr static method

Uint8List cryptoPwhashStr(
  1. Uint8List passwd,
  2. int opslimit,
  3. int memlimit
)

Implementation

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

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