Skip to content

Instantly share code, notes, and snippets.

@kkirsche
Last active August 29, 2015 14:19
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 kkirsche/ae3d948438ff690155d1 to your computer and use it in GitHub Desktop.
Save kkirsche/ae3d948438ff690155d1 to your computer and use it in GitHub Desktop.
Secure String Generator
from base64 import b64encode;
from os import urandom;
from sys import argv;
def random_bytes(bytes):
random_bytes = urandom(bytes);
return b64encode(random_bytes).decode('utf-8');
if len(argv) > 1:
byte_value = int(argv[1])
else:
byte_value = 64
print random_bytes(byte_value)
require 'securerandom'
byte_value = ARGV[0] ? Integer(ARGV[0]) : 64
puts SecureRandom.hex(byte_value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment