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

  • How to build a scalable web application using Microservices Architecture

    Millions of people worldwide stream more than two billion hours worth of video from Netflix each month. Another example is Facebook, which roughly had 2.85 billion active users in the first quarter of 2021. Talking about the e-commerce giant, Amazon receives more than 66 thousand orders per hour, and 18.5 orders per second. Whoooo! So, […]

  • Flutter vs React Native: What to choose in 2021

    If Flutter vs React Native is your burgeoning question for this year 2021, guess what you are not alone. We no longer need statistics to know about the ever-growing popularity of mobile apps across the world. According to the latest report, global consumers are now spending an average of 4.2 hours per day using apps […]

  • React Native App development: Top Reasons to Choose It in 2021

    The promising cross-platform app development framework aka React Native has garnered huge popularity in recent times. The technology enables simultaneous mobile app development for multiple platforms using a single and a fraction of resources required for native development. The react native framework has emerged to be a popular choice among businesses to fulfill their cross-platform […]

Leave a Reply

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