Skip to main content

Regular expression match hasher

Project description

hashpipe -- Regular expression match hasher

Python versions PyPI version Build status Test coverage

hashpipe is a command line tool and a Python library for hashing regular expression matches in input data.

Matches are hashed with their HMAC hex digests using a configurable key and digest algorithm, surrounded by angle brackets, and optionally prefixed with a configurable string within the brackets.

What gets hashed for each match depends on whether the regular expression contains capturing groups. If it doesn't, the entire match content is hashed. If it does, only content of the first capturing group is.

The command line tool operates as a pipe, reading standard input and outputting to standard output.

Examples

Python

import os
import re

from hashpipe import Hashpipe

hashpipe = Hashpipe(
    pattern=re.compile(br"\bfox|dog\b"),
    algorithm="sha256",
    key=os.urandom(128),
)
hashed = hashpipe.hash_matches(b"The quick brown fox jumps over the lazy dog.")
# hashed now contains something like:
# b'The quick brown <00adbe4c178e322e582e4e45c4989a204655c4b3960c0be298bc763e29dc738b> '
# b'jumps over the lazy <ee68954fe2f64931fb63756a5ecd1e22b90984c6b29fe3340b159dcff1f98244>.'

Shell

$ hashpipe --key=deadbeef --algorithm=md5 --prefix='{md5}' '^[^:]+' < /etc/passwd
<{md5}31572cc0e16e31b00f9888a18310ceab>:x:0:0:root:/root:/bin/bash
<{md5}1b4fa176c601aadfa5453b9074ba32d8>:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...

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

hashpipe-0.9.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

hashpipe-0.9.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file hashpipe-0.9.1.tar.gz.

File metadata

  • Download URL: hashpipe-0.9.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for hashpipe-0.9.1.tar.gz
Algorithm Hash digest
SHA256 137f726d4ec9e73ffb5486d89568dedf9d64800c67563f07ffbcc4ed0875ae80
MD5 4e6dff1a83387806f7fac5ce03467eba
BLAKE2b-256 497c8a4255924ee81513bbeabe362316de7ab5915a716c68d162cc062b82b3da

See more details on using hashes here.

File details

Details for the file hashpipe-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: hashpipe-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for hashpipe-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c9e2ea87d9058820850d9b340faf44a560b47199f18b375d891cb9e3678c2516
MD5 258678e98398eec4a00982d40d28addf
BLAKE2b-256 5b0f14e9892a30096df8cfbb5a65bbb6022e6abc84fc419f7a26581bc977d16c

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