From 6b6469c4192947726cec7c0284137ba2c76f4abe Mon Sep 17 00:00:00 2001 From: krasi Date: Sat, 11 May 2024 18:43:44 +0300 Subject: [PATCH] hashing passwords --- README.md | 17 ++++++++++++++++- hashing_passwords.py | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 hashing_passwords.py diff --git a/README.md b/README.md index 6507fba..810a74f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,17 @@ -# Hashing_passwords +# Hashing passwords +python hashing_passwords.py [-t {sha256,sha512,md5}] +※Default hash-type is sha256 + +Example +``` +python hashing_passwords.py nakao +< hash-type : sha256 > +63201414e0804bdc63b662bd87f0f51616ab69bd672aefe2b17fcec1ef14a995 +``` + +``` +python hashing_passwords.py nakao -t sha512 +< hash-type : sha512 > +9cae3a2096c33b6049502ac923baff9649478df62eb090bac30d5c684b2f724ecaf7c3d7744ebccb49118d2ab07d615b02a7d170fd6310f815da18e09863841a +``` \ No newline at end of file diff --git a/hashing_passwords.py b/hashing_passwords.py new file mode 100644 index 0000000..93e8a67 --- /dev/null +++ b/hashing_passwords.py @@ -0,0 +1,19 @@ +# -*- 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()) \ No newline at end of file