# Manually calculate the IPFS CID v2

**URL:** https://discuss.ipfs.tech/t/manually-calculate-the-ipfs-cid-v2/11671
**Category:** Help
**Created:** [July 2, 2021, 7:59am UTC](https://discuss.ipfs.tech/t/manually-calculate-the-ipfs-cid-v2/11671 "2021-07-02T07:59:45Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![wclayf](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/wclayf/32/4936_2.png) [@wclayf](https://discuss.ipfs.tech/u/wclayf)
#### Post date: [July 5, 2021, 9:16pm UTC](https://discuss.ipfs.tech/t/manually-calculate-the-ipfs-cid-v2/11671/4 "2021-07-05T21:16:13Z")

</div>

Here’s some prior discussions I found…

> [@How to calculate file/directory hash?](https://discuss.ipfs.tech/t/how-to-calculate-file-directory-hash/777):
>
> I’m interested in calculating IPFS hashes for various files and directories, somewhat similar to ipfs add -n. I’ve searched around, but wasn’t able to find any solid documentation on how this is calculated exactly. I’ve had a quick look through code and tried figuring it out from experimentation, and have some basic idea (files are broken into 256K chunks, wrapped in some protobuf format, hashed using SHA256 and there are index pieces which join together these small pieces, in a tree-like fashi…

> [@Generate File Hash Locally on Browser](https://discuss.ipfs.tech/t/generate-file-hash-locally-on-browser/10607):
>
> Hi everyone! I’m glad to be part of this community! Hopefully someone can help me with my following issue! What I’m trying to do is to generate the IPFS hash of a file while the user is using a PWA offline (just a web app). If I’m connected, I can just ipfs.add to add a file and get the file hash, no sweat. Now, if I’m offline I need to hash it locally and want the same output as if I added to an IPFS node. This is the code that I got so far: import { importer } from "ipfs-unixfs-importer"; …

> **[GitHub - alanshaw/ipfs-only-hash: #️⃣ Just enough code to calculate the IPFS...](https://github.com/alanshaw/ipfs-only-hash)**
>
> \#️⃣ Just enough code to calculate the IPFS hash for some data - GitHub - alanshaw/ipfs-only-hash: #️⃣ Just enough code to calculate the IPFS hash for some data

---

_[View the full topic](https://discuss.ipfs.tech/t/manually-calculate-the-ipfs-cid-v2/11671)._
