Skip to main content

Hashpic

Hashpic creates an image from the MD5 hash of your input.

Since v0.2.0 it is also possible to create an image from a SHA-512 hash.

Since v0.4.8 it is also possible to create an image from a SHAKE-256 hash with variable digest length of 4, 9, 16, 25, 36, 64, 100, 144, 225 or 255.

Since v0.3.5 it is also possible to create an image from a SHA3-512 and a BLAKE2b hash.

Since v0.4.0 it is possible to create an image as SVG.

v0.6.0 brought a huge performance boost.

Install

pip3 install hashpic

Usage

python3 -m hashpic 'Hashpic rocks!'

This should create a file output.png in your current directory. The input Hashpic rocks! should create the following image:

hashpic image

Piping from another program

All this commands should produce the same image as above.

printf 'Hashpic rocks!' | md5 | python3 -m hashpic --bypass

printf 'Hashpic rocks!' | python3 -m hashpic

SVG Mode 🎉🎉🎉

Since v0.4.0 it is possible to create an image as SVG. The following command will create a file output.svg in your current directory.

python3 -m hashpic 'Hashpic rocks!' --svg

svg

Since v0.5.0 it is possible to create circles instead of squares. But this is limited to the SVG Mode.

python3 -m hashpic 'Hashpic rocks!' --svg --round

rounded

Since v0.7.0 it is possible to create hexagons instead of squares. But this is limited to the SVG Mode. If you pass also the --round flag when using --hexagon, --round will be ignored.

python3 -m hashpic 'Hashpic rocks!' --svg --hexagon

rounded

Since v0.5.2 it is possible to add a background color to the SVG.

python3 -m hashpic 'Hashpic rocks!' --svg --round --background '#000000'

Console Mode

console

Hashing a file

It is also possible to create an image from a hash of a file. Use the --file argument for that.

python3 -m hashpic --file README.md

SHA-512 Mode

It is also possible to create an image from a SHA-512 hash. All arguments for MD5 Mode are also available for SHA512 Mode.

python3 -m hashpic --sha512 'Hashpic rocks!'

printf 'Hashpic rocks!' | python3 -m hashpic --sha512

This commands should create the following image:

sha512 image

SHAKE256 Mode

You can create an image from a SHAKE256 hash with variable digest lengths. Valid lengths are 4, 9, 16, 25, 36, 64, 100, 144, 225 and 255. You must specify the length of the digest if you want to create an image from a SHAKE256 hash.

python3 -m hashpic --shake256 --length 100 'Hashpic rocks!'

The command above should produce the following image:

shake256

More SHAKE256 examples

Click to see more examples.

Digest Length of 4

python3 -m hashpic --shake256 --length 4 'Hashpic rocks!'

shake256

Digest Length of 9

python3 -m hashpic --shake256 --length 9 'Hashpic rocks!'

shake256

Digest Length of 16

python3 -m hashpic --shake256 --length 16 'Hashpic rocks!'

shake256

Digest Length of 25

python3 -m hashpic --shake256 --length 25 'Hashpic rocks!'

shake256

Digest Length of 36

python3 -m hashpic --shake256 --length 36 'Hashpic rocks!'

shake256

Digest Length of 64

python3 -m hashpic --shake256 --length 64 'Hashpic rocks!'

shake256

Digest Length of 100

python3 -m hashpic --shake256 --length 100 'Hashpic rocks!'

shake256

Digest Length of 144

python3 -m hashpic --shake256 --length 144 'Hashpic rocks!'

shake256

Digest Length of 225

python3 -m hashpic --shake256 --length 225 'Hashpic rocks!'

shake256

Digest Length of 255

It adds a padding byte of 0xff to the end of the hash to fit it into a 16x16 grid. Please keep this in mind.

python3 -m hashpic --shake256 --length 255 'Hashpic rocks!'

shake256


SHA3 Mode

It is possible to create an image from a SHA3 hash.

python3 -m hashpic 'Hashpic rocks!' --sha3

sha3

BLAKE2b Mode

It is possible to create an image from a BLAKE2b hash.

python3 -m hashpic 'Hashpic rocks!' --blake2b

sha3

Using with Docker

Since v0.4.4 there is a dockerized version available on ghcr.io. You can pull the image from there and use it e.g.:

docker run -it -v "$(pwd)":/app --rm ghcr.io/0xflotus/hashpic:0.6.2 deadbeef --bypass --shake256 --length 4

You can also pipe to docker:

printf 'ff0030ffe589b7a4e1320f12c4c8de73' | docker run -i --rm ghcr.io/0xflotus/hashpic:0.6.2 -c --shake256 --length 16 --bypass

Examples

Bypassing a hash directly:

python3 -m hashpic ff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ff --bypass --sha512

This command will produce the following image:

bypassed

So we can call the hash above the so called chessboard hash.


You can also bypass a hash from another program:

printf 'Hashpic rocks!' | sha512sum | awk '{print $1}' | python3 -m hashpic --sha512 -c --bypass 

bypassed from another program


With all this in mind you can also use hashpic to create an image not only from a hash but e.g. from the current time in hex:

python3 -c "import time; print(hex(int(time.time()))[2:])" | python3 -m hashpic --shake256 --length 4 --bypass

Or e.g. an IP address in hexadecimal form:

# localhost hex(127.0.0.1) == 7f000001
python3 -m hashpic 7f000001 --shake256 --length 4 --bypass

# e.g. an IPv6 address of Googles DNS server
printf 2001:4860:4860:0000:0000:0000:0000:8844 | tr -d ':' | python3 -m hashpic --bypass 

If you have installed h3 you can transform a geo coordinate to an image. The example below uses the geo coordinates of the Eiffel Tower in Paris, France.

python3 -c "import h3; print(h3.geo_to_h3(48.8583230030819, 2.294450300083837, 15).zfill(18))" | python3 -m hashpic --bypass --shake256 --length 9

It is also possible to create an image from an uuid.

python3 -c "import uuid; print(str(uuid.uuid4()).replace('-', ''))" | python3 -m hashpic --bypass -c

You can also create an image from any 64-bit integer.

printf 8724325378325383578 | python3 -c "import sys, textwrap; print(''.join([hex(int(bit))[2:].zfill(2) for bit in textwrap.fill(bin(int(sys.stdin.read()))[2:].zfill(64), 1).split('\n')]))" | python3 -m hashpic --bypass --svg --round --sha3
Click to see more examples.
# compute the bypassed number
python3 -c "print(2**56-1)" | python3 -c "import sys, textwrap; print(''.join([hex(int(bit))[2:].zfill(2) for bit in textwrap.fill(bin(int(sys.stdin.read()))[2:].zfill(64),1).split('\n')]))" | python3 -m hashpic --bypass --svg --round --sha3

# bypass the binary directly
printf 0110100111001100001101001110011000111110011100110000111100111011 | python3 -c "import sys, textwrap; print(''.join([hex(int(bit))[2:].zfill(2) for bit in textwrap.fill(bin(int(sys.stdin.read(), 2))[2:].zfill(64),1).split('\n')]))" | python3 -m hashpic --bypass --svg --round --sha3

# map the colors 
printf 0110100111001100001101001110011000111110011100110000111100111011 | python3 -c "import sys, textwrap; print(''.join(map(lambda x: '00' if x == '01' else 'ff', [hex(int(bit))[2:].zfill(2) for bit in textwrap.fill(bin(int(sys.stdin.read(), 2))[2:].zfill(64),1).split('\n')])))" | python3 -m hashpic --bypass --svg --round --sha3

Disclaimer

The color palette in data.py was influenced by the string-color library. Thanks for this!

Release files for hashpic 0.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hashpic 0.7.3
File Size Uploaded
hashpic-0.7.3.tar.gz 16.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hashpic 0.7.3
File Interpreter ABI Platform
hashpic-0.7.3-py3-none-any.whl Python 3 none any Details

Total release size: 34.5 kB

Release files / hashpic-0.7.3.tar.gz

Download URL hashpic-0.7.3.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
3951853efe796d895bb70bd34f0fb183a805f2cbd86bcfed385dbe8361278925
BLAKE2b-256 checksum
How to use checksums
22fe63e896831a3d3db3ae6eb7aa62020ebf8c181bc7bca35ff59691cf9441c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Release files / hashpic-0.7.3-py3-none-any.whl

Download URL hashpic-0.7.3-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60655668ceec1d923d86c52b14af53f9166dd44c21fc867c326ac3f13b13d649
BLAKE2b-256 checksum
How to use checksums
40dc576c36818e09cd6094bf7116a8f8bf25198317232e834a39081a154423fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Release history Release notifications | RSS feed

This release

0.7.3 This release

2 release files

0.7.2

3 release files

0.7.1

3 release files

0.7.0

3 release files

0.6.3

3 release files

0.6.2

3 release files

0.6.1

3 release files

0.6.0

3 release files

0.5.2

3 release files

0.5.1

3 release files

0.5.0

3 release files

0.4.18

3 release files

0.4.17

3 release files

0.4.16

3 release files

0.4.15

3 release files

0.4.14

3 release files

0.4.13

3 release files

0.4.12

3 release files

0.4.11

3 release files

0.4.10

3 release files

0.4.9

3 release files

0.4.7

4 release files

0.4.6

3 release files

0.4.5

3 release files

0.4.4

2 release files

0.4.3

3 release files

0.4.2

3 release files

0.4.1

3 release files

0.4.0

3 release files

0.3.9

3 release files

0.3.8

3 release files

0.3.7

3 release files

0.3.6

3 release files

0.3.5

3 release files

0.3.4

3 release files

0.3.3

3 release files

0.3.2

3 release files

0.3.1

3 release files

0.3.0

3 release files

0.2.8

3 release files

0.2.7

3 release files

0.2.5

3 release files

0.2.3

3 release files

0.2.2

3 release files

0.2.1

3 release files

0.2.0

3 release files

0.1.6

3 release files

0.1.5

3 release files

0.1.4

3 release files

0.1.3

3 release files

0.1.1

3 release files

0.1.0

3 release files

0.0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page