Thursday, August 18, 2011

Converting password/string to Phonetic Alphabet [Python]

So, every time my buddies stop by, ask, what's the WIFI's password? then I usually give them a piece of paper with a 160 Bit password of 20 Characters like:
{[Ck~Yv~xV9~-R9EMi-k so they go like: can you read this back to me?

So as I've been doing some code, I wanted to be lazy and get my generated passwords in the phonetic alphabet in order to make it easy to pass on:

and this is the result:

#!/usr/bin/python
import sys

if len(sys.argv) < 2:
print "[-] Nothing to do, please provide the password or string: python script.py myPa$$w0rd""
sys.exit()

d = {"a":"alpha","b":"bravo","c":"charlie","d":"delta","e":"echo","f":"foxtrot","g":"golf","h":"hotel","i":"india","j":"juliett","k":"kilo","l":"lima","m":"mike","n":"november","o":"oscar","p":"papa","q":"quebec","r":"romeo","s":"sierra","t":"tango","u":"uniform","v":"victor","w":"whiskey","x":"x-ray","y":"yankee","z":"zulu","-":"dash","0":"Zero", "1":"One", "2":"Two", "3":"Three", "4":"Four", "5":"Five", "6":"Six", "7":"Seven", "8":"Eight", "9":"Nine"}

print("[*] Your password/string of lenght:%d can be read as follows:\n" % (len(sys.argv[1])))
for char in sys.argv[1]:
if char.lower() in d:
if char.lower() == char:
print d[char]
else:
print d[char.lower()].upper()
else:
print char

----
output example:

$ python passToWords.py {[Ck~Yv~xV9~-R9EMi-k
[*] Your password/string of lenght:20 can be read as follows:

{
[
CHARLIE
kilo
~
YANKEE
victor
~
x-ray
VICTOR
Nine
~
dash
ROMEO
Nine
ECHO
MIKE
india
dash
kilo

No comments:

Post a Comment