-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ Generate IPFS CIDs (Content Identifiers) from a slice of bytes. | |
keywords = ["ipfs", "cid", "content", "identifier", "hash"] | ||
authors = ["Abid Omar <[email protected]>"] | ||
exclude = ["tests/*", "examples/*", "data/*"] | ||
version = "1.0.0" | ||
version = "2.0.0" | ||
edition = "2021" | ||
license = "MIT" | ||
homepage = "https://github.com/omarabid/ipfs-cid" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// ipfs-cid is a tool to generate the CID of a file. | ||
// The CLI is simple and only takes a file path as an argument and prints the CID to STDOUT. | ||
pub fn main() { | ||
let args: Vec<String> = std::env::args().collect(); | ||
if args.len() != 2 { | ||
eprintln!("Usage: ipfs-cid <file>"); | ||
std::process::exit(1); | ||
} | ||
let path = &args[1]; | ||
let file = std::fs::read(path).expect("Failed to read file"); | ||
let cid = ipfs_cid::generate_cid_v0(&file); | ||
match cid { | ||
Ok(cid) => println!("{}", cid), | ||
Err(e) => eprintln!("Failed to generate CID: {}", e), | ||
} | ||
} |