Skip to content

Instantly share code, notes, and snippets.

@takai
Created June 30, 2012 01:11
Show Gist options
  • Save takai/3021657 to your computer and use it in GitHub Desktop.
Save takai/3021657 to your computer and use it in GitHub Desktop.
Generate random strings for password
16.times.map { rand(1 + ?~.ord - _ = ?!.ord) + _ }.pack('c*')
@aji
Copy link

aji commented Jun 30, 2012

from string import ascii_letters
with open('/dev/urandom') as f:
    print(''.join([ascii_letters[ord(byte) % len(ascii_letters)] for byte in f.read(16)]))

Python isn't as pretty as Ruby :(

@takai
Copy link
Author

takai commented Jun 30, 2012

looks stubborn for me 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment