Skip to content

Instantly share code, notes, and snippets.

@stiandre
Created November 26, 2014 09:26
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 stiandre/9f9085ab052a52f68078 to your computer and use it in GitHub Desktop.
Save stiandre/9f9085ab052a52f68078 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import crypt
import sys
import random
saltchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
def salt():
return "$6$" + "".join(random.sample(saltchars, 8))
def hash(plain):
return crypt.crypt(arg, salt())
if __name__ == "__main__":
random.seed()
for arg in sys.argv[1:]:
sys.stdout.write("%s\n" % (hash(arg),))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment