encryptRaw method

Uint8List encryptRaw(
  1. Uint8List password,
  2. Uint8List salt,
  3. int logRounds,
  4. Uint32List cdata,
)

Implementation

Uint8List encryptRaw(
  Uint8List password,
  Uint8List salt,
  int logRounds,
  Uint32List cdata,
) {
  int rounds;
  int i;
  int j;
  var clen = cdata.length;
  if ((logRounds < 4) || (logRounds > 30)) {
    throw Exception('Bad number of rounds');
  }
  rounds = (1 << logRounds);
  if (salt.length != bcryptSaltLen) {
    throw Exception('Bad salt length');
  }
  initKey();
  _ekskey(salt, password);
  for ((i = 0); i != rounds; i++) {
    key(password);
    key(salt);
  }
  for ((i = 0); i < 64; i++) {
    for ((j = 0); j < (clen >> 1); j++) {
      encipher(cdata, j << 1);
    }
  }
  var ret = Uint8List(clen * 4);
  (i = 0);
  (j = 0);
  for (; i < clen; i++) {
    ret[j++] = ((cdata[i] >> 24) & 0xff);
    ret[j++] = ((cdata[i] >> 16) & 0xff);
    ret[j++] = ((cdata[i] >> 8) & 0xff);
    ret[j++] = (cdata[i] & 0xff);
  }
  return ret;
}