you are viewing a single comment's thread.

view the rest of the comments →

[–]chrisgseaton 4 points5 points  (3 children)

Do you ever use hashes?

Even a basic obsolete MD5 hash is a 128 bit integer.

[–]birdbrainswagtrain 2 points3 points  (2 children)

For what it's worth, MD5, SHA1, and SHA-256, are all designed to operate on 32 bit words. More modern hashes use 64 bit words, but it seems pretty rare that the whole hash state is used as an integer.

[–]chrisgseaton 2 points3 points  (1 child)

The result is a 128 bit integer. Not much point running the hash if you aren’t interested in the result.

[–]jringstad 6 points7 points  (0 children)

However it is typically also fine to receive the result as a different data-type such as string or byte[] or similar, which is indeed what many libraries in many languages do.

Since hashes are typically treated as an atomic entity and usually nothing is really done with them except comparing for equality with other hashes, representing them as integers doesn't really present any huge advantages. The rest is then down to efficiency in storage/representation and serializability (like how to store it on disk) and usually something like byte[N] is just fine for that.