Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 18, 2019 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/81a4056c8c1627935bdf82d01ee91d65 to your computer and use it in GitHub Desktop.
Save parzibyte/81a4056c8c1627935bdf82d01ee91d65 to your computer and use it in GitHub Desktop.
Generar cadena aleatoria segura en Python https://parzibyte.me/blog/2018/12/06/contrasena-segura-python/
"""
Generar una contraseña o cadena aleatoria y segura criptográficamente
Visita: parzibyte.me/blog
"""
from secrets import choice
caracteres = 'abcdefghijklmnopqrtsuvwxyz1234567890'
longitud = 8 # La longitud que queremos
cadena_aleatoria = ''.join(choice(caracteres) for caracter in range(longitud))
print("La cadena es: ", cadena_aleatoria)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment