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, which is much faster.
pip3 install hashpic
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:
All this commands should produce the same image as above.
printf 'Hashpic rocks!' | md5 | python3 -m hashpic --bypass
printf 'Hashpic rocks!' | python3 -m hashpic
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
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
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:
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:
The --slow flag
You can use the --slow
flag to run a generalized method instead of a hardcoded one. But this have some performance issues.
Hardcoded:
Generalized:
Since v0.4.0 it is possible to create an image as SVG. Creating SVG files is blazingly fast:
Click to see more examples.
python3 -m hashpic --shake256 --length 4 'Hashpic rocks!'
python3 -m hashpic --shake256 --length 9 'Hashpic rocks!'
python3 -m hashpic --shake256 --length 16 'Hashpic rocks!'
python3 -m hashpic --shake256 --length 25 'Hashpic rocks!'
python3 -m hashpic --shake256 --length 36 'Hashpic rocks!'
python3 -m hashpic --shake256 --length 64 'Hashpic rocks!'
python3 -m hashpic --shake256 --length 100 'Hashpic rocks!'
python3 -m hashpic --shake256 --length 144 'Hashpic rocks!'
Maybe this command will take a few seconds to complete.
python3 -m hashpic --shake256 --length 225 'Hashpic rocks!'
This command will take a lot more seconds to complete because it uses currently the slower generic method to create the image. It also 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!'
It is possible to create an image from a SHA3 hash.
python3 -m hashpic 'Hashpic rocks!' --sha3
It is possible to create an image from a BLAKE2b hash.
python3 -m hashpic 'Hashpic rocks!' --blake2b
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.4.4 deadbeef --bypass --shake256 --length 4
You can also pipe to docker:
printf 'ff0030ffe589b7a4e1320f12c4c8de73' | docker run -i --rm ghcr.io/0xflotus/hashpic:0.4.6 -c --shake256 --length 16 --bypass
Bypassing a hash directly:
python3 -m hashpic ff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ff --bypass --sha512
This command will produce the following image:
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
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
The color palette in data.py
was influenced by the string-color
library.
Thanks for this!