How to calculate Cid locally?

how can i calculate cid locally .
like below

i only find js repo. is there any java implement?

is there anyone help?

what about this GitHub - ipfs-shipyard/java-ipfs-http-client: A Java implementation of the HTTP IPFS API ?

You get all ipfs commands over the http

i need calculate my file CID hash locally. rather than through http api.
so i needn’t upload to ipfs node to save internet traffic

oh in that case why don’t you see the implementations of the CID itself GitHub - multiformats/cid: Self-describing content-addressed identifiers for distributed systems you can use it without the ipfs.

You need this:

i believe he needs the Java version and he listed that repo already.

I’m failing to understand is this about calculating the CID or using the offline capability of the ipfs. if it’s just about the CID you can create it from any buffer.

any example code for calculate CID from buffer.
i’m not familiar with java

you need to use multihash then pass that into the CID constructor. Check this >> GitHub - multiformats/js-cid: CID implementation in JavaScript