From 3ccd95169a1bba93d6549bf8ee8a753dff10e950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=AD=E5=B0=BE=E5=90=8F=E5=BF=97?= Date: Sun, 12 Jul 2020 11:02:19 +0900 Subject: [PATCH 1/2] add hashing passwords directory/script. --- projects/hashing passwords/README.md | 17 +++++++++++++++++ .../hashing passwords/hashing_passwords.py | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 projects/hashing passwords/README.md create mode 100644 projects/hashing passwords/hashing_passwords.py diff --git a/projects/hashing passwords/README.md b/projects/hashing passwords/README.md new file mode 100644 index 000000000..6c5a6211e --- /dev/null +++ b/projects/hashing passwords/README.md @@ -0,0 +1,17 @@ +# hashing passwords +## Execute +`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/projects/hashing passwords/hashing_passwords.py b/projects/hashing passwords/hashing_passwords.py new file mode 100644 index 000000000..06f74921b --- /dev/null +++ b/projects/hashing passwords/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()) From 2c7963d2b653745c98fb831ff0ee6f31a2cab8a0 Mon Sep 17 00:00:00 2001 From: m044de <46442823+m044de@users.noreply.github.com> Date: Sun, 12 Jul 2020 11:04:21 +0900 Subject: [PATCH 2/2] Update README.md --- projects/hashing passwords/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/hashing passwords/README.md b/projects/hashing passwords/README.md index 6c5a6211e..13b80bfae 100644 --- a/projects/hashing passwords/README.md +++ b/projects/hashing passwords/README.md @@ -11,7 +11,7 @@ $ python hashing_passwords.py nakao ``` ``` -python hashing_passwords.py nakao -t sha512 +$ python hashing_passwords.py nakao -t sha512 < hash-type : sha512 > 9cae3a2096c33b6049502ac923baff9649478df62eb090bac30d5c684b2f724ecaf7c3d7744ebccb49118d2ab07d615b02a7d170fd6310f815da18e09863841a -``` \ No newline at end of file +```