Clamps the lower and upper bits as required by the specification.
Returns bytes
with clamped bits.
Length of the bytes
should be at least 32.
var l = new List<int>.generate(32, (int i) => i + i); // [0, ..., 60, 62]
bitClamp(new Uint8List.fromList(l)); // [0, ..., 60, 126]
Source
Uint8List bitClamp(Uint8List bytes) { bytes[0] &= 248; bytes[31] &= 63; bytes[31] |= 64; return bytes; }