GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - scop/hashpipe: Regular expression match hasher

BranchesTags
Open more actions menu

Latest commit

 

History

442 Commits
442 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
bin
bin
 
 
hashpipe
hashpipe
 
 
.dir-locals.el
.dir-locals.el
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.gitlint
.gitlint
 
 
.pre-commit-config.yaml
.pre-commit-config.yaml
 
 
.pymarkdown.json
.pymarkdown.json
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
MANIFEST.in
MANIFEST.in
 
 
NOTICE
NOTICE
 
 
README.md
README.md
 
 
noxfile.py
noxfile.py
 
 
pyproject.toml
pyproject.toml
 
 
requirements-dev.txt
requirements-dev.txt
 
 
requirements-test.txt
requirements-test.txt
 
 
setup.cfg
setup.cfg
 
 
setup.py
setup.py
 
 
test_hashpipe.py
test_hashpipe.py
 
 

Repository files navigation

hashpipe -- Regular expression match hasher

Python versions PyPI version CI 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. It has optional shell completion support using argcomplete, intended to be registered with --no-defaults, for example

eval "$(register-python-argcomplete --no-defaults hashpipe)"

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
...

About

Regular expression match hasher

Resources

Readme
Apache-2.0 license
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.