jc_sdhash - SDHash Python Wrapper
This Python package provides a simple, functional wrapper for the SDHash binary, allowing you to generate and compare SDBF hashes directly from Python. Note: This package only works on Linux.
Installation
You can install jc_sdhash either from PyPI or from the source.
Option 1: Install from PyPI
pip install jc_sdhash
Usage The package provides a functional API, similar to ssdeep. Import it as jc_sdhash and use its functions directly.
Importing the Package
import jc_sdhash as sd
Usage Options Option 1: Generate an SDBF Hash and Print to Console Generate a hash for a file and print it to standard output:
import jc_sdhash as sd
# Generate the SDBF hash for a file
result = sd.generate("inputfile.txt")
print(result)
Option 2: Generate an SDBF Hash and Save to File Generate a hash and save it to a specified output file:
import jc_sdhash as sd
# Generate the SDBF hash and save it to "output.sdbf"
sd.generate("inputfile.txt", output_filepath="output.sdbf")
Option 3: Compare Two SDBF Hash Files Compare two SDBF files and print the similarity score:
import jc_sdhash as sd
# Compare two SDBF files
result = sd.compare("file1.sdbf", "file2.sdbf")
print(result)
Option 4: Validate an SDBF File Validate the integrity of an SDBF file:
import jc_sdhash as sd
# Validate an SDBF file
result = sd.validate("file1.sdbf")
print(result)
Function Details
generate(filepath, output_filepath=None)
Generates an SDBF hash for the given file.
If output_filepath is provided, the hash is saved there; otherwise, it’s returned as a string.
compare(file1, file2)
Compares two SDBF files and returns the similarity score as a string.
validate(sdbf_file)
Validates an SDBF file and returns the result as a string.
Requirements
- Python 3.6+
- Linux-based OS (this package only works on Linux)
- The
sdhashbinary (included in the package) - Read access to input files and write access for output files (if saving hashes)
Troubleshooting
Missing Binary
If you get a FileNotFoundError, ensure the sdhash binary is in the jc_sdhash/ directory and executable:
chmod +x jc_sdhash/sdhash
Metadata
Release files for jc-sdhash 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jc_sdhash-0.2.1.tar.gz | 331.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jc_sdhash-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 992.3 kB
Release files / jc_sdhash-0.2.1.tar.gz
| Download URL | jc_sdhash-0.2.1.tar.gz |
|---|---|
| Size | 331.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
12729438e1bf4f2604a6939bb4b569ebb45486ab2659216af7f2b877cfbfe96b
|
|
BLAKE2b-256 checksum How to use checksums |
cbedb85987018c086aa96b09ce385540dfb0453be774e86ce614c2db9ed9fba3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / jc_sdhash-0.2.1-py3-none-any.whl
| Download URL | jc_sdhash-0.2.1-py3-none-any.whl |
|---|---|
| Size | 661.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
168a85cd6d0a22696701546c864f08c170670191d592f6a100c8ed8af2ed2b87
|
|
BLAKE2b-256 checksum How to use checksums |
91005f53cd8635420b98cf2588bf873285039ded6459f8a6c82d9bcf34dc1841
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|