generateWorkingKey static method
Implementation
static List<int> generateWorkingKey(bool encrypting, Uint8List key) {
if (key.length < 8) {
throw ArgumentError('Chave DES deve ter 8 bytes.');
}
final key64 = _bytesToInt64(key, 0);
final permuted = _permute(key64, _pc1, 64);
int c = (permuted >> 28) & 0x0FFFFFFF;
int d = permuted & 0x0FFFFFFF;
final subKeys = List<int>.filled(16, 0);
for (int i = 0; i < 16; i++) {
c = _rotl28(c, _rotations[i]);
d = _rotl28(d, _rotations[i]);
final cd = (c << 28) | d;
subKeys[i] = _permute(cd, _pc2, 56);
}
if (!encrypting) {
return subKeys.reversed.toList(growable: false);
}
return subKeys;
}