Crates.io | ipfs-cid |
lib.rs | ipfs-cid |
version | 2.0.0 |
source | src |
created_at | 2023-07-06 17:49:40.065964 |
updated_at | 2024-04-09 18:58:35.612351 |
description | Generate IPFS CIDs (Content Identifiers) from a slice of bytes. |
homepage | https://github.com/omarabid/ipfs-cid |
repository | https://github.com/omarabid/ipfs-cid |
max_upload_size | |
id | 910148 |
size | 34,650 |
This crates provides a simple function to generate IPFS CIDs (Content Identifiers) from a slice of bytes.
Two functions are available: generate_cid
and generate_cid_hash
. The first
one returns the full CID object as defined in the cid crate (version 0.5.1). The second
one returns the hash only as a String
.
let bytes_vector = std::fs::read("data/file0").unwrap();
let bytes_slice = bytes_vector.as_slice();
let cid_hash = generate_cid_hash(bytes_slice).unwrap();
println!("{}", cid_hash);
This should return
QmUBnCzebDwZgkXp9ZkHHKQNfaeWn2Dw8p8vNz4GN4jBLa
The file is accessible from IPFS at the same hash: QmUBnCzebDwZgkXp9ZkHHKQNfaeWn2Dw8p8vNz4GN4jBLa
A basic CLI is avaiable in 2.0.0. It returns v0 CID of the passed file.
Usage
$ ipfs-cid file
This project is licensed under