Skip to content

Instantly share code, notes, and snippets.

@brunurd
Last active June 15, 2020 01:56
Show Gist options
  • Save brunurd/7ca91f43a102b7014d93e10c68a4eee1 to your computer and use it in GitHub Desktop.
Save brunurd/7ca91f43a102b7014d93e10c68a4eee1 to your computer and use it in GitHub Desktop.
from __future__ import print_function
import random
import string
import sys
def gen_secret(secret_size):
secret = ""
invalid_chars = [' ','\n','\t','\r','\x0b','\x0c','"','\'','`','\\']
for i in range(0, secret_size):
c = ''
while True:
c = string.printable[random.randrange(0,len(string.printable))]
if c not in invalid_chars:
break
secret += c
return secret
if __name__ == "__main__":
try:
value = int(sys.argv[1])
print(gen_secret(value))
except:
print(gen_secret(256))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment