1
1
# -*- coding: utf-8 -*-
2
+ """Simple Python console app for storing passwords."""
2
3
import base64
3
4
import os
4
5
import random
15
16
16
17
17
18
class Color :
19
+ """Python specified values used for text formatting"""
18
20
# Sources:
19
21
# https://stackoverflow.com/questions/8924173/how-do-i-print-bold-text-in-python
20
22
# http://ascii-table.com/ansi-escape-sequences.php
@@ -31,6 +33,7 @@ class Color:
31
33
32
34
33
35
class Program :
36
+ """Infos about the program"""
34
37
name = 'Python Password' # Work in progress
35
38
version = '0.1' # Alpha
36
39
author = 'Jakub S.'
@@ -39,6 +42,10 @@ class Program:
39
42
40
43
41
44
def header ():
45
+ """
46
+ Shows welcome text
47
+ :return: Formatted text
48
+ """
42
49
foo = ''
43
50
for i in range (len (Program .name ) + len (Program .version ) + 10 ):
44
51
foo += '-'
@@ -61,11 +68,12 @@ def clear():
61
68
62
69
63
70
def confirm ():
71
+ """Prints confirmation and waits for ENTER"""
64
72
input ('\n ---\n \n Press ENTER to continue...' )
65
73
66
74
67
75
def show_records (records = None ):
68
- # Default query - passwords' names
76
+ """Shows specified values from database, for default passwords' names"""
69
77
if records is None :
70
78
records = query ('SELECT `name` FROM `passwords`;' )
71
79
@@ -115,7 +123,7 @@ def check_files():
115
123
116
124
# ``key`` file
117
125
try :
118
- open (file ('master.key' ), 'r' )
126
+ open (file ('master.key' ))
119
127
except FileNotFoundError :
120
128
print ('Key file not found! Creating one...' )
121
129
generate_key ()
@@ -166,6 +174,7 @@ def rand_password(length: int = 16):
166
174
167
175
# Option 1
168
176
def generate_key ():
177
+ """Generates salt.key file based on user input"""
169
178
password_input = input ('Provide master password: ' )
170
179
password = password_input .encode ()
171
180
@@ -199,6 +208,7 @@ def generate_key():
199
208
200
209
# Option 2
201
210
def get_password ():
211
+ """Decrypts password from database and saves it to clipboard"""
202
212
print ('Available passwords:\n ' )
203
213
show_records ()
204
214
@@ -229,6 +239,7 @@ def get_password():
229
239
230
240
# Option 3
231
241
def set_password ():
242
+ """Saves encrypted and salted password to database"""
232
243
password_name = input ('Provide password name (visible): ' )
233
244
password_value = getpass ('Provide password value (or leave empty for random): ' )
234
245
@@ -249,6 +260,7 @@ def set_password():
249
260
250
261
# Option 4
251
262
def del_password ():
263
+ """Deletes password from database, require confirmation"""
252
264
print ('Available passwords:\n ' )
253
265
show_records ()
254
266
@@ -274,6 +286,7 @@ def del_password():
274
286
275
287
# Option 5
276
288
def quick_start ():
289
+ """Shows general info about the program"""
277
290
print (f'Program name: { Program .name } \n '
278
291
f'Current version: { Program .version } \n '
279
292
f'Author: { Program .author } \n '
0 commit comments