commit 5b4d21b786ae8f8b5126ac447d9755caa372dcfe Author: Greg Gauthier Date: Mon Mar 11 16:29:14 2019 +0000 initial commit diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..b723d01 --- /dev/null +++ b/Pipfile @@ -0,0 +1,11 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] + +[requires] +python_version = "3.7" diff --git a/cfg/config.json b/cfg/config.json new file mode 100644 index 0000000..edb23df --- /dev/null +++ b/cfg/config.json @@ -0,0 +1,3 @@ +{ + "keyfile":"keyfile.json" +} \ No newline at end of file diff --git a/configuration.py b/configuration.py new file mode 100644 index 0000000..c75419a --- /dev/null +++ b/configuration.py @@ -0,0 +1,10 @@ +import json + + +class Configuration: + def __init__(self): + with open('cfg/config.json') as cfgfile: + self.data = json.load(cfgfile) + + def get_keyfilename(self): + return self.data["keyfile"] diff --git a/credentials.py b/credentials.py new file mode 100644 index 0000000..8e02896 --- /dev/null +++ b/credentials.py @@ -0,0 +1,49 @@ +import hashlib +import json +import uuid +from random import randint +from secrets import choice +from string import ascii_letters, digits + +from configuration import Configuration + + +class Credentials: + def __init__(self): + with open(Configuration().get_keyfilename(), mode="r+") as keydata: + self.keys = json.load(keydata) + + def get_keys(self): + return self.keys + + def add_key(self, service, username, password): + + pass + + def get_key_by_service(self, service): + return self.keys[service] + + @staticmethod + def gen_password(mn=12, mx=64): + return [ + ''.join(choice(ascii_letters + digits) + for _ in range(randint(mn, mx))) + ] + + @staticmethod + def hash_password(password): + salt = uuid.uuid4().hex + return hashlib.sha512( + salt.encode() + password.encode()).hexdigest() + ':' + salt + + @staticmethod + def check_password(hashed_password, user_password): + password, salt = hashed_password.split(':') + return password == hashlib.sha512( + salt.encode() + user_password.encode()).hexdigest() + + @staticmethod + def dsa_encode(password): + hash_object = hashlib.new('DSA') + hash_object.update(password) + return hash_object.h diff --git a/keyfile.json b/keyfile.json new file mode 100644 index 0000000..7383443 --- /dev/null +++ b/keyfile.json @@ -0,0 +1,10 @@ +{ + "twitter": { + "username": "@alwaysexiting", + "password": "some-password" + }, + "youtube": { + "username": "exitingthecave@gmail.com", + "password": "somepassword" + } +} diff --git a/testing.txt b/testing.txt new file mode 100644 index 0000000..be953a8 --- /dev/null +++ b/testing.txt @@ -0,0 +1,4 @@ +line one +line two +line three +line fourline fiveline six \ No newline at end of file