hash_val function

Uint8List hash_val(
  1. dynamic val
)

@param {string|Buffer|BigInt} val @returns {Buffer}

Implementation

// ignore: non_constant_identifier_names
Uint8List hash_val(dynamic val) {
  if (val is String) {
    return hash_string(val);
  }
  if (val is Uint8List || val is Uint8Buffer) {
    return hash_bytes(Uint8List.fromList(val));
  }
  if (val is BigInt) {
    return hash_U64(val);
  }
  if (val is num) {
    return hash_U64(BigInt.from(val));
  }
  if (val is List) {
    return hash_array(val);
  }
  if (val is Map) {
    return hash_of_map(val);
  }
  throw "hash_val($val) unsupported";
}