Last active
January 8, 2017 17:10
-
-
Save Vages/d76b5f429bcce28f23af932a9ae58150 to your computer and use it in GitHub Desktop.
A script to generate a random numeric pin along with a string of possible ‘phone keyboard phrases’ (using the letters shown on a phone keyboard, setting 1 to punctuation and 0 to language-specific letters).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice | |
available_numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] | |
numbers_to_letters = {"1":["."], | |
"2":["A", "B", "C"], | |
"3":["D", "E", "F"], | |
"4":["G", "H", "I"], | |
"5":["J", "K", "L"], | |
"6":["M", "N", "O"], | |
"7":["P", "Q", "R", "S"], | |
"8":["T", "U", "V"], | |
"9":["W", "X", "Y", "Z"], | |
"0":["Æ", "Ø", "Å"]} | |
def generate_pin(length=4): | |
pin = "" | |
for i in range(length): | |
pin += choice(available_numbers) | |
return pin | |
def generate_mnemomic_phrase(numbers, prefix_string=""): | |
if not numbers: | |
print(prefix_string) | |
else: | |
for l in numbers_to_letters[numbers[0]]: | |
generate_mnemomic_phrase(numbers[1:], prefix_string + l) | |
if __name__ == "__main__": | |
a = generate_pin() | |
print(a) | |
generate_mnemomic_phrase(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment