edited term colors to also include black and white

This commit is contained in:
jan6 2021-02-19 09:21:15 +02:00
parent 5926e95d23
commit 34efdede44
3 changed files with 6 additions and 2 deletions

View File

@ -10,7 +10,7 @@ Usage: wordmap.py <wordlist file> <string to hash> [string to append]
where `string to append` is optional, and itself has \x1b[0m appended to it (the "reset formatting" code to stop color bleeding)
for example `python3 wordmap.py wordlists/corncob_lowercase.txt "example words"` would result in `serenading`
and to use the terminal colors: `python3 wordmap.py wordlists/term16color.txt "example" "example"`
and to use the terminal colors: `python3 wordmap.py wordlists/term16color.txt "colored" "colored"`
it can also be imported, something like `python3 -c 'a="example";from wordmap import wordmap;wordmap("wordlists/term16color.txt",a);print(a+"\x1b[0m")'`

View File

@ -1,3 +1,4 @@




@ -5,6 +6,7 @@








View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
from sys import argv
from math import floor
from hashlib import blake2b
@ -26,7 +27,8 @@ def wordmap(wordlist_file: str, input: str, digest_size: int = 4):
words_max = len(words)
digest_max = int.from_bytes(b'\xff' * digest_size, "big")
input_hash = hashfun(input, digest_size=digest_size)
input_hash_mapped = scale(input_hash, (0, digest_max), (0, words_max))
input_hash_mapped = scale(input_hash, (0, digest_max), (0, words_max-1))
#floor, to make sure it doesn't round over the max
input_hash_mapped = round(input_hash_mapped)
print(words[input_hash_mapped], end="")