Skip to main content

Official hashdd Python SDK

Project description

# hashdd

pyhashdd is a library for building and using hash databases. It also serves as the client library for interacting with the [hashdd.com](https://www.hashdd.com) [API](https://github.com/hashdd/api_documentation), an online hash database.

# Installation

With all prerequisites installed, you can install pyhashdd with `pip`:

```
pip install hashdd
```

## Prerequisites

### Ubuntu
```
sudo apt-get install libfuzzy-dev libmhash-dev libffi-dev libssl-dev
```

### OSX/Darwin Prerequisites
```
brew install ssdeep
```

**Note: ** Due to a [bug in py-mhash](https://github.com/niwinz/py-mhash/pull/4), pyhashdd on OSX may cause a free error when generating certain hash types. As a workaround until the maintainer accepts the open pull request, please install from this repository:

```
pip install git+https://github.com/brad-anton/py-mhash.git
```

# Command Line Examples

To calculate the hash of a specific file (`-f sample`) and look it up (`-l`) in the hashdd.com database:
```
hashdd -l -f sample.exe
```

To recusively (`-r 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 -b -r goodfiles/
```

With the bloom filter created, the `-b` 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 (`-b`):

```
hashdd -b -f sample.exe
```

To calculate all hashes (`--all`) and output them to the screen (`-s`):
```
hashdd -s -f sample.exe --all
```

To calculate a specific hash type:
```
hashdd -s -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)
```

# API Client Examples

To query the hashdd.com API for a basic status:

```
>>> from hashdd.api import client
>>> c = client(None) # Basic status does not require an api_key, thus the None argument
>>> c.status('39E1D81353B1002E5043317CE75FA966FDD8DB215E57BC6F72681673CDDA561C')
{u'39E1D81353B1002E5043317CE75FA966FDD8DB215E57BC6F72681673CDDA561C': {u'known_level': 1, u'result': u'SUCCESS'}, u'result': u'SUCCESS'}
```

Project details


Release history Release notifications

This version
History Node

0.0.18

History Node

0.0.17

History Node

0.0.16

History Node

0.0.15

History Node

0.0.14

History Node

0.0.13

History Node

0.0.12

History Node

0.0.11

History Node

0.0.10

History Node

0.0.9

History Node

0.0.8

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
hashdd-0.0.18-py2-none-any.whl (342.0 kB) Copy SHA256 hash SHA256 Wheel 2.7 Jul 22, 2017
hashdd-0.0.18.tar.gz (560.1 kB) Copy SHA256 hash SHA256 Source None Jul 22, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page