Skip to main content


Showing posts from September, 2021

Security: What Percentage of Passwords are Pure ASCII?

I was wondering what percentage of passwords are pure ASCII. Hence, I threw together some code: #!/usr/bin/env python3 PASSWORD_LIST = "example.txt" num_pure_ascii = 0 num_iso_8859_1_not_ascii = 0 num_passwords = 0 with open(PASSWORD_LIST, mode="rb") as f: for line in f: password = line.rstrip(b"\n") num_passwords += 1 try: password.decode('ASCII') num_pure_ascii += 1 print("Pure ASCII:", password, flush=True) except UnicodeDecodeError: try: password.decode('UTF-8').encode('ISO-8859-1') num_iso_8859_1_not_ascii += 1 print("ISO-8859-1 (but not pure ASCII):", password, flush=True) except (UnicodeEncodeError, UnicodeDecodeError): print("Not encodable into ASCII or ISO-8859-1:", password, flush=True) percentage_pure_as