validateFixedLengthBytes static method

List<int> validateFixedLengthBytes({
  1. required List<int> bytes,
  2. required int length,
  3. bool unmodifiable = true,
  4. String? objectName,
})

Implementation

static List<int> validateFixedLengthBytes(
    {required List<int> bytes,
    required int length,
    bool unmodifiable = true,
    String? objectName}) {
  if (bytes.length != length) {
    throw MessageException("Invalid ${objectName ?? 'hash'} length.",
        details: {"Excepted": length, "length": bytes.length});
  }
  return BytesUtils.toBytes(bytes, unmodifiable: unmodifiable);
}