Close

The SHA-1 Hash Function

In this blog post, we are going to explore a core concept of the “Git” Technology :

the SHA-1 Hash function.

Briefly, any file in a computer can be thought of as a series of bytes, each of which is 8 bits. If  you put these bytes from left to right, all files can be thought of as very large numbers represented in binary (base-2) format. Cryptographers have come up with a very interesting function called SHA-1 which has the following curious property: any binarynumber, up to 264 bits, can be rapidly mapped to a 160 bit (20 byte) number that we can visualize as a 40 character  long number in hexadecimal (base-16) format. Here is an example using node’s crypto module:

sha-1-hash-function

The point is that, even binary numbers which are very close,  map to completely different 20 byte SHA-1 values, which means SHA-1(x) is very different from most “normal” functions like cos(x)

SHA-1 Hash function

Because a hash can be assumed to map 1-to-1 to a file, rather than conveying the full file’s contents to distinguish it, you can just use the hash. Indeed, you can just use a hash to uniquely identify any string of bits less than 264 bits in length.

Latest stories

  • Things to Consider Before Hiring the Right Developer

    As the tech talent war continues to rage, it is no wonder that hiring the right developer takes forever. Managers face numerous difficulties not just hiring but retaining the right talent.If we are to go by statistics, the average time-to-hire for tech positions in the USA is 35 days. A realistic expectation is crucial while […]

  • 4 Ways To Reduce your App Development Costs by 50%

    Being multi-channel has become synonyms with the modern digital environment.Brand presence in these channels is critical to reach potential customers making it a vital business challenge of  the digital era.  Mobile apps have become an integral part of modern business. They are an extension of your brand. Considered as the most powerful business tool, apps […]

  • Tips to build a productive startup culture in your development company

    The word Startup paints a picture of tech-savvy professionals driving casual dress codes and sipping coffee from biodegradable cups in a space with enviable interior design, ping pong tables and bean bags. Ouch, the stereotype hurts! There is more to startups than bean bags and beer taps, it is the startup culture that fuels innovation […]

Leave a Reply

Your email address will not be published. Required fields are marked *