| Crates.io | jsonhash |
| lib.rs | jsonhash |
| version | 0.2.0 |
| created_at | 2025-10-12 21:54:22.17362+00 |
| updated_at | 2025-10-13 15:39:30.353301+00 |
| description | A command-line tool to generate hash values for files. SHA256 and MD5. Output and Error messages in JSON format. |
| homepage | |
| repository | https://github.com/fruafr/rust-jsonhash |
| max_upload_size | |
| id | 1879767 |
| size | 41,968 |
A command-line tool to compute hash of file content and filepath, returning the result as JSON.
jsonhash <filepath>
jsonhash -a md5 <filepath>
jsonhash --alg md5 <filepath>
jsonhash -a sha256 <filepath>
jsonhash -alg sha256 <filepath>
The tool returns a JSON object with the following fields:
request: the request objectresponse: the response objecterror: the error objectrequest always is present.
response and error are mutually exclusive.
method: the name of this tool. 'jsonhash'version: the version of this toolts: timestamp in nanoseconds when the request was receivedparams : contains the parameters as "key":value
filepath: filepath you provided in your requestalg: Algorithm used (sha256 or md5)id: value provided with --id, else nullts: timestamp in nanoseconds when the request was respondedabsfilepath: Absolute path of the filehash: Hash of the file contentfilename: Name of the fileshortpath: Short path relative to current directorypathid: Hash of the absolute filepathshortpathid: Hash of the short pathjsonhash test.txt
Returns:
{
"request": {
"method": "jsonhash",
"params": {
"filepath": "test.txt",
"id": "1",
"alg": "md5"
},
"ts": 1760367864236976611,
"version": "0.2.0"
},
"response": {
"ts": 1760367864237186637,
"absfilepath": "/tmp/jsonhash/test.txt",
"hash": "9458edef495a29ee98b40a63ed80e9b7",
"filename": "test.txt",
"shortpath": "jsonhash/test.txt",
"pathid": "50b53521888c464428cbb6189ef50602",
"shortpathid": "d746f98d3344150895a94a752349ce82"
}
}
error message will contain:
code: code at integer
message: error message as String
| Code | Value | Description |
|---|---|---|
| 3 | HASH-ALGORITHM-INVALID | incorrect / unsupported hash algorithm |
| 5 | NOT-A-FILE | The filepath is not a file (Directories are not supported) |
| 6 | FILE-DOES-NOT-EXIST | The filepath does not exist. No such address: The specified address is unavailable. |
| 66 | FILE-OPENING-ERROR | file cannot be opened |
| 70 | HASH-DIGEST-COMPUTATION-ERROR | An error occured during the computation of the hash digest |
{
"request": {
"method": "jsonhash",
"params": {
"filepath": "/temp/non-existing-file",
"id": null,
"alg": "sha256"
},
"ts": 1760368083128138305,
"version": "0.2.0"
},
"error": {
"code": 6,
"message": "FILE-DOES-NOT-EXIST"
}
}
cargo build --release
cargo test
test.txttest.sh