Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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])
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