bit32ListFromUInt8List method

List<int> bit32ListFromUInt8List()

Implementation

List<int> bit32ListFromUInt8List() {
  final Uint8List bytes = this;
  final int additionalLength = bytes.length % 4 > 0 ? 4 : 0;
  final List<int> result =
      (bytes.length ~/ 4 + additionalLength).generate((_) => 0);
  for (int i = 0; i < bytes.length; i++) {
    final int resultIdx = i ~/ 4;
    final int bitShiftAmount = (3 - i % 4).toInt();
    result[resultIdx] |= bytes[i] << bitShiftAmount;
  }
  for (int i = 0; i < result.length; i++) {
    result[i] = result[i] << 24;
  }
  return result;
}