Skip to main content

Official hashdd Python SDK

Project description

hashdd

pyhashdd is a library for building and using hash databases.

Installation

With all prerequisites installed, you can install pyhashdd with pip, the [all] extras directive will install everything to need for extended hashes like ssdeep and pysha3:

pip install hashdd[all]

Alternative Installations

Default Installation

By default, we don't want to assume you have all of the required prerequisites installed, so we just install the absolute bare minimum for you to use the library as an import.

pip install hashdd

Extended Hashes Installation

Many of our "extended" hashes are essentially wrappers around popular OS libraries. These libraries are OS-level dependencies that we dont want to force you to use. So but default we don't install them but give you the option to install them all if you'd like.

pip install hashdd[all]

Docker

Build the container from the git root:

docker build -t hashdd .

Create a directory to scan, and copy our sample.exe into it.

mkdir files_to_scan/
cp tests/data/sample.exe files_to_scan/

Mount files_to_scan/ and scan away!

docker run --rm -v "$PWD"/files_to_scan:/files_to_scan hashdd hashdd compute -d /files_to_scan

Prerequisites

Ubuntu

sudo apt-get install libfuzzy-dev libmhash-dev libffi-dev libssl-dev

OSX/Darwin Prerequisites

brew install ssdeep

hashddcli Examples

To recusively (-d goodfiles/) calculate the SHA256 hashes of files in the goodfiles/ directory and add those hashes to a new bloom filter (the bloom filter is stored in hashdd.bloom):

hashdd bloom -d goodfiles/

With the bloom filter created, the bloom option now compares calculated hashes to the bloom. To calculate the SHA256 hash of sample.exe (-f sample.exe) and check if it is within the bloom filter (bloom):

hashdd bloom -f sample.exe

To calculate (compute) all hashes (--all) and output them to the screen:

hashdd compute -f sample.exe --all

To calculate a specific hash type:

hashdd compute -f sample.exe -a md5w

Library Examples

To hash a file using all algorithms and features, then store the results in Mongo:

>>> from hashdd import hashdd
>>> h = hashdd(filename='sample.exe')
>>> from pymongo import MongoClient
>>> db = MongoClient().hashdd
>>> db.hashes.insert_one(h.result)

Testing

python -m unittest discover -s tests/

py-mhash and mhashlib

Back in 2017 we fixed an issue in py-mhash which was merged into the git repository, however this fix was not built as part of the distribution in PyPi. Rather then rely on the package maintainer any further, we've bundled in py-mhash with hashdd. Please see the py-mash license for copyright information.

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

hashdd-0.0.27.tar.gz (726.7 kB view details)

Uploaded Source

Built Distribution

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

hashdd-0.0.27-py3-none-any.whl (376.2 kB view details)

Uploaded Python 3

File details

Details for the file hashdd-0.0.27.tar.gz.

File metadata

  • Download URL: hashdd-0.0.27.tar.gz
  • Upload date:
  • Size: 726.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for hashdd-0.0.27.tar.gz
Algorithm Hash digest
SHA256 46572d12ccfe447872ac8bcee765bdcacb07dcf8a20282963355703bc6ee803a
MD5 bf9580a68244785dfe8dc90520da03ae
BLAKE2b-256 d0995bae8832860830a21e6e1759cffef1068989feae1d4436147b03d7bf06fd

See more details on using hashes here.

File details

Details for the file hashdd-0.0.27-py3-none-any.whl.

File metadata

  • Download URL: hashdd-0.0.27-py3-none-any.whl
  • Upload date:
  • Size: 376.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for hashdd-0.0.27-py3-none-any.whl
Algorithm Hash digest
SHA256 94a307489ad476c1d7259f5a84322a7f1add3a81f8e483797345dce75db26686
MD5 e1783ecc96cafd6adb50f715e5d5f2ed
BLAKE2b-256 ac0429f94cf5a3d147fa99f2ca950c9772e935b58742c5df2fea18b248dabcb6

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