implement password encrpytion in credentials

This commit is contained in:
Greg Gauthier 2019-03-12 15:06:52 +00:00
parent 64149b54fc
commit 4e7d0d778a
2 changed files with 7 additions and 5 deletions

View File

@ -4,11 +4,9 @@ url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
pycrypto = "*"
fernet = "*"
[packages]
pycrypto = "*"
fernet = "*"
[requires]

View File

@ -1,3 +1,4 @@
from password import Password
from pwdfile import Pwdfile
@ -11,10 +12,13 @@ class Credentials:
def read_cred(self, service):
return self.creds[service]
def create_cred(self, service, username, password):
def create_cred(self, service, username, password=None):
if password is None:
password = Password.generate(mn=64)
new_entry = {
"username": username,
"password": password
"password": Password().encrypt(password)
}
self.creds[service] = new_entry
Pwdfile().write(self.creds)
@ -24,7 +28,7 @@ class Credentials:
if username is None and password is not None:
self.creds[service] = {
"username": current_entry["username"],
"password": password
"password": Password().encrypt(password)
}
elif username is not None and password is None:
self.creds[service] = {