Hash Function
A cryptographic hash function takes in data of any size and returns a fixed length output.
SHA256 is a very well known hash function that takes input of any arbitrary length and returns a 256 bit unique output
Here is an example of SHA256 hash function output in R
> library(sodium)
> sha256(charToRaw("Let's make a Hash of this"))
[1] 8a 9b 18 11 2a 2c 7a 9b 89 94 48 43 22 21 26 b1 27 ef 0f 1f 7f 90 1d d8 92 1c cb 16 73 e9 cb 45
> sha256(charToRaw("Let's make a Hash of this."))
[1] 0a 15 b9 9c 8a 55 cf d9 15 00 a0 2b 60 48 bc 7c 60 58 cd f5 44 55 56 eb 26 f4 e9 5b 29 37 4f f2
The output of the strings "Let's make a Hash of this" or "Let's make a Hash of this." are different 256 bit strings (8 bit x 32)
Even if we take a very long text or a black space, the output will be 256 bit long and unique.
> sha256(charToRaw("Let's make a Hash of this veryyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text"))
[1] 78 bc db 6e 2e f0 25 d9 05 33 7a 63 46 f2 87 d9 cb 10 10 46 40 7e f7 79 c8 27 1f 37 12 54 4a a8
> sha256(charToRaw(""))
[1] e3 b0 c4 42 98 fc 1c 14 9a fb f4 c8 99 6f b9 24 27 ae 41 e4 64 9b 93 4c a4 95 99 1b 78 52 b8 55
It is important to remember that the Hash output for a given data is always unique. This property is particularly useful to check the integrity of the data. If the data changes even slightly the hash of it will change. It is much more convenient to compare the hash of the data than to compare a very large chuck of data.
Collision Free Property
Nobody can find two different strings X and Y such that their hashes are the same. This helps us postulate that if two hash outputs are different then the associated data (or string) are also different. [Note that it is theoretically possible have collisions, but a good hash function makes it difficult to find that collision]