# Verify IPFS Multihash

IPFS has a unique way of identifying the data you store with multihash. For example, using ipfs add an_image.png will actually return a mutlihash which you can use to retrieve the file. However, it seems plausible for the front-end (JavaScript) to have the ability to verify it after the content is downloaded. Don’t worry, you are about to grasp it!

## Decode Multihash

Multihash actually contains the hash method we use and the hash digest output of the content, encoded by base58. Using multihashes library will make you understand it. In IPFS, the hash method is always sha2-256 right now. The following class CID will help you convert between sha256 hash and multihash.

## The input of SHA256

However, the input of SHA256 is the content alone, it’s actually wrapped by protobuf. To get a deep understanding of it, we can do a simple test.

• create a file containes ipfs-multihash and add it to IPFS

Its multihash CID will be QmfQj4DUWEudeFdWKVzPaTbYimdYzsp14DZX1VLV1BbtdN.

• Get the SHA256 hash from the multihash.

The result will be 0xfda1ea739791f6784b13590d4be03f6a6dad136eb3ac7615522ad0d910f66cd9

• hash the file

The SHA256 result is b41a3a2a90e84bf773e03a8bd0d0090f5beb42332a6faaa8718db083ebb130dd,

which clearly is not fda1ea739791f6784b13590d4be03f6a6dad136eb3ac7615522ad0d910f66cd9

• Using block get instead

Finally, the SHA256 result is fda1ea739791f6784b13590d4be03f6a6dad136eb3ac7615522ad0d910f66cd9.

So what is the content of block get anyway?

• Using protoc to see what actually happens

The result is actually great

According to how-recreate-a-hash-digest-of-a-multihash-in-ipfs, we know it contains Type, Data and fileSize. A simplified and working example is here: