My Password vault Design

The First Step

After much thought, doodling on paper, and some test code I came up with the following:

Note: I found Python encryption/decryption code on the web.

Three Useful Menu Functions

import user_interface as ui # ------------------------------------------------------------------- # ---- query yes/no # ------------------------------------------------------------------- def query_yes_no(p=' [yY]: '): ans = ui.get_user_input(p) if not ans: return False if ans[0] == 'y' or ans[0] == 'Y': return True return False # ------------------------------------------------------------------- # ---- get vault db name # ------------------------------------------------------------------- def get_vault_dbname(vault_context): db = vault_context["vault"]["dbname"] print() print(f'The currrent vault\'s db name is ({db})') tf = query_yes_no('Use this db name [yY]? ') if tf: return None db = ui.get_user_input('Enter a db name: ') if not db: return None return db # ------------------------------------------------------------------- # ---- menu action - change vault db name # ------------------------------------------------------------------- def change_vault_dbname_action(vault_context): db = get_vault_dbname(vault_context) if not db: print() print('no db name entered - no action taken') return vault_context["vault"]["dbname"] = db print() print(f'vault\'s db name changed to ({db})') return

The Second step

Code the design

More Details

All searches use sub-string matches, and may return more that one entry.

The way to insure only one entry is returned is to do an ID search.

A unique ID (integer) is assigned to each entity when it is created. IDs start at 1 and incremented +1 each time.

Deleting entries will leave gaps in the range of IDs. They are no longer contiguous. This is not a problem, but just in case, a function is provided to renumber entries starting at 1. This will make the IDs contiguous.

FYI: How to Encrypt JSON in Python