Skip to content

Instantly share code, notes, and snippets.

@owenthewizard
Created September 2, 2018 05:24
Show Gist options
  • Save owenthewizard/ea8b2b00d00fc03182635bf16c1468a6 to your computer and use it in GitHub Desktop.
Save owenthewizard/ea8b2b00d00fc03182635bf16c1468a6 to your computer and use it in GitHub Desktop.
Simple password generator. Probably not secure.
#!/usr/bin/env python3
# genpass by owenthewizard
from os import urandom
from base64 import b64encode
config = {
# Number of bytes of entropy to use when generating password
"bytes": 16,
# Limit password to this many characters
"chars": 8
}
# Characters that look too similar in many fonts or are otherwise unsuitable
# for passwords
# Equals sign is padding for base64
bad_chars = {"1": "", "l": "", "O": "", "0": "", "=": ""}
# Yuck!
print(b64encode(urandom(config["bytes"])).decode("utf-8").translate(bad_chars)[:config["chars"]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment