Skip to content

Instantly share code, notes, and snippets.

@vfrico
Created October 31, 2015 10:29
Show Gist options
  • Save vfrico/82ae2e02d10553a6b67e to your computer and use it in GitHub Desktop.
Save vfrico/82ae2e02d10553a6b67e to your computer and use it in GitHub Desktop.
Crear números aleatorios en Python
#!/usr/bin/env python3
RANDBYTES = 280 #Número de Bytes aleatorios que tendrá de longitud
NUM = 1000 #Cantidad de números a sacar
import os
dist = open("randoms.txt",'w+')
for i in range(0,NUM):
ran = int.from_bytes(os.urandom(RANDBYTES), byteorder='little')
#dist.write(hex(ran) + "\n") #Imprime los números en hexadecimal
dist.write(str(ran) + "\n") #Imprime los números en decimal
dist.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment