Do something with mozilla::SHA1Sum::Hash

NEW
Unassigned

Status

()

6 years ago
5 years ago

People

(Reporter: justin.lebar+bug, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Right now, mozilla::SHA1Sum::Hash is a typedef for uint8_t[20].

That's not very useful, because when I see code like:

  SHA1Sum::Hash hash = /* whatever */;
  for (int i = 0; i < sizeof(hash); i++) {
    foo(hash[i]);
  }

it's not clear what type hash[i] has; nor is it clear that the loop condition is correct.  Explicit is better than implicit, so better would be

  uint8_t[SHA1Sum::HashLength] hash;
  for (...) {...}

There are a few things we could do here.  We could just eliminate this typedef and use uint8_t[20], which would be fine with me.  Or we could make SHA1Sum::Hash a proper class with ToByteArray() and ToHexString(char*) functions.

Any thoughts on this?
You need to log in before you can comment on or make changes to this bug.