isEqual method

bool isEqual(
  1. dynamic other
)

Checks if the message digest equals to other.

Here, the other can be a one of the following:

This function will return True if all bytes in the other matches with the bytes of this object. If the length does not match, or the type of other is not supported, it returns False immediately.

Implementation

bool isEqual(other) {
  if (other is HashDigest) {
    return isEqual(other.bytes);
  } else if (other is ByteBuffer) {
    return isEqual(buffer.asUint8List());
  } else if (other is TypedData && other is! Uint8List) {
    return isEqual(other.buffer.asUint8List());
  } else if (other is String) {
    return isEqual(fromHex(other));
  } else if (other is Iterable<int>) {
    if (other is List<int>) {
      if (other.length != bytes.length) {
        return false;
      }
    }
    int i = 0;
    for (int x in other) {
      if (i >= bytes.length || x != bytes[i++]) {
        return false;
      }
    }
    return true;
  }
  return false;
}