Package: hashpic
HashpicHashpic creates an image from theMD5hash of your input.Sincev0.2.0it is also possible to create an image from aSHA-512hash.Sincev0.4.8it is also possible to create an image from aSHAKE-256hash with variable digest length of4,9,16,25,36,64,100,144,225or255.Sincev0.3.5it is also possible to create an image from aSHA3-512and aBLAKE2bhash.Sincev0.4.0it is possible to create an image asSVG.v0.6.0brought a huge performance boost.Installpip3 install hashpicUsagepython3-mhashpic'Hashpic rocks!'This should create a fileoutput.pngin your current directory.
The inputHashpic rocks!should create the following image:Piping from another programAll this commands should produce the same image as above.printf'Hashpic rocks!'|md5|python3-mhashpic--bypassprintf'Hashpic rocks!'|python3-mhashpicSVG Mode 🎉🎉🎉Sincev0.4.0it is possible to create an image asSVG. The following command will create a fileoutput.svgin your current directory.python3-mhashpic'Hashpic rocks!'--svgSincev0.5.0it is possible to create circles instead of squares. But this is limited to theSVG Mode.python3-mhashpic'Hashpic rocks!'--svg--roundSincev0.7.0it is possible to create hexagons instead of squares. But this is limited to theSVG Mode.
If you pass also the--roundflag when using--hexagon,--roundwill be ignored.python3-mhashpic'Hashpic rocks!'--svg--hexagonSincev0.5.2it is possible to add a background color to the SVG.python3-mhashpic'Hashpic rocks!'--svg--round--background'#000000'Console ModeHashing a fileIt is also possible to create an image from a hash of a file. Use the--fileargument for that.python3-mhashpic--fileREADME.mdSHA-512 ModeIt is also possible to create an image from aSHA-512hash. All arguments forMD5 Modeare also available forSHA512 Mode.python3-mhashpic--sha512'Hashpic rocks!'printf'Hashpic rocks!'|python3-mhashpic--sha512This commands should create the following image:SHAKE256 ModeYou can create an image from aSHAKE256hash with variable digest lengths. Valid lengths are4,9,16,25,36,64,100,144,225and255. You must specify the length of the digest if you want to create an image from aSHAKE256hash.python3-mhashpic--shake256--length100'Hashpic rocks!'The command above should produce the following image:More SHAKE256 examplesClick to see more examples.Digest Length of 4python3-mhashpic--shake256--length4'Hashpic rocks!'Digest Length of 9python3-mhashpic--shake256--length9'Hashpic rocks!'Digest Length of 16python3-mhashpic--shake256--length16'Hashpic rocks!'Digest Length of 25python3-mhashpic--shake256--length25'Hashpic rocks!'Digest Length of 36python3-mhashpic--shake256--length36'Hashpic rocks!'Digest Length of 64python3-mhashpic--shake256--length64'Hashpic rocks!'Digest Length of 100python3-mhashpic--shake256--length100'Hashpic rocks!'Digest Length of 144python3-mhashpic--shake256--length144'Hashpic rocks!'Digest Length of 225python3-mhashpic--shake256--length225'Hashpic rocks!'Digest Length of 255It adds apadding byte of 0xffto the end of the hash to fit it into a16x16 grid. Please keep this in mind.python3-mhashpic--shake256--length255'Hashpic rocks!'SHA3 ModeIt is possible to create an image from aSHA3hash.python3-mhashpic'Hashpic rocks!'--sha3BLAKE2b ModeIt is possible to create an image from aBLAKE2bhash.python3-mhashpic'Hashpic rocks!'--blake2bUsing with DockerSincev0.4.4there is a dockerized version available onghcr.io. You can pull the image from there and use it e.g.:dockerrun-it-v"$(pwd)":/app--rmghcr.io/0xflotus/hashpic:0.6.2deadbeef--bypass--shake256--length4You can also pipe to docker:printf'ff0030ffe589b7a4e1320f12c4c8de73'|dockerrun-i--rmghcr.io/0xflotus/hashpic:0.6.2-c--shake256--length16--bypassExamplesBypassing a hash directly:python3-mhashpicff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ffff00ff00ff00ff0000ff00ff00ff00ff--bypass--sha512This command will produce the following image:So we can call the hash above the so calledchessboard hash.You can also bypass a hash from another program:printf'Hashpic rocks!'|sha512sum|awk'{print $1}'|python3-mhashpic--sha512-c--bypassWith 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-mhashpic--shake256--length4--bypassOr e.g. an IP address in hexadecimal form:# localhost hex(127.0.0.1) == 7f000001python3-mhashpic7f000001--shake256--length4--bypass# e.g. an IPv6 address of Googles DNS serverprintf2001:4860:4860:0000:0000:0000:0000:8844|tr-d':'|python3-mhashpic--bypassIf you have installedh3you can transform a geo coordinate to an image.
The example below uses the geo coordinates of theEiffel Tower in Paris, France.python3-c"import h3; print(h3.geo_to_h3(48.8583230030819, 2.294450300083837, 15).zfill(18))"|python3-mhashpic--bypass--shake256--length9It is also possible to create an image from anuuid.python3-c"import uuid; print(str(uuid.uuid4()).replace('-', ''))"|python3-mhashpic--bypass-cYou can also create an image from any 64-bit integer.printf8724325378325383578|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-mhashpic--bypass--svg--round--sha3Click to see more examples.# compute the bypassed numberpython3-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-mhashpic--bypass--svg--round--sha3# bypass the binary directlyprintf0110100111001100001101001110011000111110011100110000111100111011|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-mhashpic--bypass--svg--round--sha3# map the colorsprintf0110100111001100001101001110011000111110011100110000111100111011|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-mhashpic--bypass--svg--round--sha3DisclaimerThe color palette indata.pywas influenced by thestring-colorlibrary.
Thanks for this!