Home cracking password w/python
Post
Cancel

cracking password w/python

This is a python program that prints out all possible products, or permutations, of 4-digit passcodes:

from string import digits
from itertools import product

for passcode in product(digits, repeat=4):
    print(passcode)

This one use letters instead of digits:

from string import ascii_letters
from itertools import product

for passcode in product(ascii_letters, repeat=4):
    print(passcode)

On a typical keyboard, we’ll have 32 symbols, in addition to 26 uppercase letters, 26 lowercase letters, and 10 numbers, for a total of 94 different symbols. So if we have an 8-character passcode, we’ll be able to choose between 94 x 94 x 94 x 94 x 94 x 94 x 94 x 94 possibilities, which is over 6 quadrillion.

from string import ascii_letters, digits, punctuation
from itertools import product

for passcode in product(ascii_letters + digits + punctuation, repeat=8):
    print(passcode)

From the very well done Harvard CS50

This post is licensed under CC BY 4.0 by the author.