clampKey static method

Uint8List clampKey(
  1. Uint8List bytes,
  2. int byteLength
)

Implementation

static Uint8List clampKey(Uint8List bytes, int byteLength) {
  if (bytes.length != byteLength) {
    throw InvalidSigningKeyError();
  }
  var resultBytes = bytes.toUint8List();
  resultBytes[0] &= 0xF8; // clear the last 3 bits
  resultBytes[31] &= 0x7F; // clear the 1st bit
  resultBytes[31] |= 0x40; // set the 2nd bit
  return resultBytes;
}