Skip to main content

A Python wrapper for the SDHash binary.

Project description

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 sdhash binary (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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jc_sdhash-0.2.1.tar.gz (331.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jc_sdhash-0.2.1-py3-none-any.whl (661.1 kB view details)

Uploaded Python 3

File details

Details for the file jc_sdhash-0.2.1.tar.gz.

File metadata

  • Download URL: jc_sdhash-0.2.1.tar.gz
  • Upload date:
  • Size: 331.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for jc_sdhash-0.2.1.tar.gz
Algorithm Hash digest
SHA256 12729438e1bf4f2604a6939bb4b569ebb45486ab2659216af7f2b877cfbfe96b
MD5 3b86fa1c2f15ac6429e699a781bc0b1b
BLAKE2b-256 cbedb85987018c086aa96b09ce385540dfb0453be774e86ce614c2db9ed9fba3

See more details on using hashes here.

File details

Details for the file jc_sdhash-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: jc_sdhash-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 661.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for jc_sdhash-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 168a85cd6d0a22696701546c864f08c170670191d592f6a100c8ed8af2ed2b87
MD5 8d02772a1c5856d83f7985c0c6554ace
BLAKE2b-256 91005f53cd8635420b98cf2588bf873285039ded6459f8a6c82d9bcf34dc1841

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page