Hashing password using Python Script

  • Post author:
  • Post comments:0 Comments
  • Reading time:19 mins read

Enhance the security of your applications and services with the power of password hashing in Python. In this project, you’ll learn how to create a Python script to securely hash passwords, a fundamental practice in safeguarding sensitive data.

Whether you’re a beginner looking to fortify your coding skills or an experienced developer focused on enhancing security, this step-by-step guide will walk you through the process of hashing passwords, making them resistant to unauthorized access. Join us in the quest to protect user data and strengthen cybersecurity through Python scripting!


# -*- cofing: utf-8 -*-
import argparse
import hashlib

# parsing
parser = argparse.ArgumentParser(description='hashing given password')
parser.add_argument('password', help='input password you want to hash')
parser.add_argument('-t', '--type', default='sha256',choices=['sha256', 'sha512', 'md5'] )
args = parser.parse_args() 

# hashing given password
password = args.password
hashtype = args.type
m = getattr(hashlib,hashtype)()
m.update(password.encode())

# output
print("< hash-type : " + hashtype + " >")
print(m.hexdigest())
Publisher
Latest posts by Publisher (see all)

Publisher

Publisher @ideasorblogs

Leave a Reply