added option for appending text
mainly for easier handling of color & formatting escapes in cli form
This commit is contained in:
parent
8f82f2721a
commit
5926e95d23
|
@ -4,10 +4,13 @@
|
|||
maps a string to a word from given word list,
|
||||
created because I wanted a consistent hash equivalence thingy and only found some overcomplicated ones
|
||||
|
||||
`Usage: wordmap.py <wordlist file> <word to hash>`
|
||||
```
|
||||
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, on *nix-like systems you can use `(i="example";python3 wordmap.py wordlists/term16color.txt "$i"|tr -d \\n;printf "%s\33[0m\n" "$i")`
|
||||
and to use the terminal colors: `python3 wordmap.py wordlists/term16color.txt "example" "example"`
|
||||
|
||||
it can also be imported, something like `python3 -c 'a="example";from wordmap import wordmap;wordmap("wordlists/term16color.txt",a);print(a+"\x1b[0m")'`
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ def wordmap(wordlist_file: str, input: str, digest_size: int = 4):
|
|||
|
||||
if __name__ == "__main__":
|
||||
def usage():
|
||||
print(f"Usage: {argv[0]} <wordlist file> <word to hash>")
|
||||
print(f"Usage: {argv[0]} <wordlist file> <string to hash> [string to append]")
|
||||
quit(1)
|
||||
|
||||
try:
|
||||
|
@ -41,9 +41,13 @@ if __name__ == "__main__":
|
|||
usage()
|
||||
wordlist_file = argv[1]
|
||||
input = argv[2]
|
||||
try:
|
||||
extrawords=argv[3]
|
||||
except IndexError:
|
||||
extrawords=""
|
||||
except IndexError:
|
||||
usage()
|
||||
#input = "example"
|
||||
#wordlist_file = "wordlists/term16color.txt"
|
||||
wordmap(wordlist_file, input)
|
||||
print(input + "\x1b[0m")
|
||||
print(extrawords+"\x1b[0m")
|
||||
|
|
Loading…
Reference in New Issue