IPFS learning - hash

Hashes

Hash function is to accept some arbitrary function input and returns a fixed length value. Depending on a given particular value used by the hash algorithm, for example, the SHA-. 1 (used in the GIT), the SHA-256 , or BLAKE2 , but a given input using a hashing algorithm always return the same output.
For example: Enter the following:

Hello world

Using SHA-1 is output:

0x7B502C3A1F48C8609AE212CDFB639DEE39673F5E

However, using the same input SHA-256 will output the following:

0x64EC88CA00B268E5BA1A35678A1B5316D212F4F366B2477232534A8AECA37F3C

The second hash value is greater than the first length, because SHA-1 to create a 160-bit hash value, SHA-256 and creates a hash value of 256 bits. Also, the front of 0xjust one indicator that tells us the following hash is represented as base 16 (or hexadecimal) numbers.
Hash can be represented base2(by a different base base16, , base32etc.). In fact, IPFS this as its content identifier part and use Multibase protocol supports a variety of basic representation.
For example, "Hello World" of the use of SHA-256 hash value base32is expressed as:

mtwirsqawjuoloq2gvtyug2tc3jbf5htm2zeo4rsknfiv3fdp46a

Cryptographic hash feature

Cryptographic hash with a very important feature:

  • Uncertainty - the same input message always return the same output hash.
  • Irrelevant - a small change in the message should generate a completely different hash.
  • Uniqueness - the same hash generated from two different message is not feasible.
  • Unidirectional - guess or calculate the hash value from the input message is not feasible.

It turns out that these features also means that we can use to identify any data encryption hash: hash is unique to us from the calculated data, and it will not be too long (hash is a fixed length, so SHA-256 hash is the size of 1 GB of video file is still only 32 bytes), so it does not take up a lot of resources sent over the network.

This is like IPFS distributed systems is essential, in this system, we hope to many parts store and retrieve data from. IPFS running computer can ask with all peer connection, if there is a file with a specific hash value, if one has a specific hash value, then they will be sent back to the entire file. No short and unique identifiers (such as password hash) can not be achieved. This technique is called "content addressable" - because the content itself is used to form the address, rather than to store their information in the computer and disk location.

Guess you like

Origin www.cnblogs.com/cbkj-xd/p/12059785.html