Created
February 26, 2017 05:30
-
-
Save sebassdc/35329e05ecfac03e8b966226c4e00044 to your computer and use it in GitHub Desktop.
Generate pseudosecure paswords CLI
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
#! /usr/bin/python | |
import sys | |
import random as rd | |
from string import ascii_lowercase as beta | |
from string import ascii_uppercase as alfa | |
def passgen(longu): | |
colection = "" | |
caracters = "?/.+@/#%".replace("", " ").split() | |
for i in range(longu): | |
des = rd.randrange(1, 101) | |
if des < 40: | |
colection += str(rd.randrange(1, 10)) | |
elif des < 60: | |
x = rd.randrange(0, len(caracters)) | |
colection += caracters[x] | |
elif des < 80: | |
colection += alfa[rd.randrange(0, len(alfa))] | |
else: | |
colection += beta[rd.randrange(0, len(beta))] | |
return colection | |
def main(): | |
longitud = len(sys.argv) | |
if longitud == 1: | |
print "Clave de 8 caracteres por defecto generada" | |
print passgen(8) | |
elif longitud == 2: | |
x = int(sys.argv[1]) | |
print "clave de %d caracteres generada" % x | |
print passgen(x) | |
else: | |
print "La sintaxis debe ser passgen [longitud de contrasena]" | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment