Skip to content

Instantly share code, notes, and snippets.

@kyhau
Created February 28, 2016 03:45
Show Gist options
  • Save kyhau/04a97db88815469beda8 to your computer and use it in GitHub Desktop.
Save kyhau/04a97db88815469beda8 to your computer and use it in GitHub Desktop.
Hash a password (text) using bcrypt.hashpw with a random salt
import argparse
import bcrypt
def main():
"""
simple script to get a hashed password from text
"""
parser = argparse.ArgumentParser()
parser.add_argument('--text', required=True, help='input text')
args = parser.parse_args()
input_text = args.text.strip()
# Hash a password using the OpenBSD bcrypt scheme
print bcrypt.hashpw(input_text, bcrypt.gensalt())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment