Updated gen command to new notes system

This commit is contained in:
2022-01-10 22:59:52 -05:00
parent e00fd64c66
commit a218e77e41
2 changed files with 14 additions and 9 deletions
+11 -6
View File
@@ -303,17 +303,22 @@ def gen(): # generates a password for a new or an existing entry
_username = str(input('Username: '))
_pass_length = int(input('How many characters should be in the password? '))
_pass_type = str(input('Should the password be simple (for compatibility) or complex (for security)? (s/C) '))
if _pass_type != 's':
_pass_type = string.ascii_letters + string.digits + string.punctuation
if _pass_type == 's':
if _pass_type.lower() == 's':
_pass_type = string.ascii_letters + string.digits
else:
_pass_type = string.ascii_letters + string.digits + string.punctuation
_pass_gen = ''.join(random.SystemRandom().choice(_pass_type) for _ in range(_pass_length))
if argument != 'gen update' and argument != 'gen -u':
_url = str(input('URL: '))
_notes = str(input('Additional notes: ')) # TODO update w/new notes system
_add_note = input('Add a note to this entry? (y/N) ')
_shm_folder, _shm_entry = shm_gen()
open(f"/dev/shm/{_shm_folder}/{_shm_entry}", 'w').writelines(_username + '\n' + _pass_gen + '\n' + _url +
'\n\n' + _notes + '\n\n')
if _add_note.lower() == 'y':
system(f"nano /dev/shm/{_shm_folder}/{_shm_entry}-n")
_notes = open(f"/dev/shm/{_shm_folder}/{_shm_entry}-n", 'r').read()
else:
_notes = ''
open(f"/dev/shm/{_shm_folder}/{_shm_entry}", 'w').writelines(_username + '\n' + _pass_gen + '\n' + _url + '\n\n'
+ _notes + '\n\n')
encrypt(_shm_folder, _shm_entry, _entry_name)
system(f"gpg -d '{directory}{_entry_name}.gpg'")
else: