Last active
September 16, 2017 09:43
-
-
Save teemuy/f011827e709daa2e580d5e934bee347b to your computer and use it in GitHub Desktop.
Shell alias to generate cryptographically strong strings for passwords/keys (needs Python2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Put the line below in your ~/.profile | |
# You can then say "genrandstr 10" to get a string of 10 random bytes, base64 encoded. | |
# Works on macOS, should work on Linux as long as there's Python 2.x installed. | |
# | |
alias genrandstr="python2 -c 'import sys,os,base64;print len(sys.argv)==2 and base64.b64encode(os.urandom(int(sys.argv[1]))) or \"Usage: genrandstr <numbytes>\"'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment