def main(): args = parser.parse_args() data = load_data() if not data: cli.init_data() if cli.unlock_entries(): if not args.entry and args.list: cli.list_entries() elif not args.entry: parser.print_help() exit('\n Error: No entry specified') if args.add: cli.add_entry(args.entry) elif args.update: cli.update_entry(args.entry) elif args.remove: cli.delete_entry(args.entry) else: if args.entry: cli.decrypt_entry(args.entry) else: print('Invalid Master Password')
def unlock_entries(): data = load_data() attempt = getpass('Enter your master password: '******'master'], data['key']) if attempt == master: return True return False
def decrypt_entry(entry): data = load_data() if entry not in data['entry']: exit(f'Entry for {entry} does not yet exist') password = decrypt(data['entry'][entry], data['key']) pyperclip.copy(password) print(f'Password for {entry} copied to the clipboard')
def __init__(self): super().__init__() self.title = "Fassword - A Password Manager" self.position = (50, 50) self.dimens = (500, 500) self.create_password = CreatePassword() self.data = load_data() self.entries = QListWidget() self.unlocked = False self.initUI()
def init_data(): data = load_data() print('\nInitializing Fassword\n') print('You must choose a master password\n') password = choose_password() master, key = encrypt(password) data = create_storage(master, key) save_data(data) exit('\nFassword is ready. Type fass -h for options\n')
def update_entry(entry): data = load_data() if entry not in data['entry']: exit(f'Entry for {entry} does not yet exist') print(f'\nEnter the new password for {entry}') password = choose_password() encrypted = encrypt(password, data['key'])[0] data['entry'][entry] = encrypted print('\nPassword Updated') save_data(data)
def add_entry(entry): data = load_data() if entry in data['entry']: exit('\nEntry already exists') print(f'\nChoose a password for {entry}') password = choose_password() encrypted = encrypt(password, data['key'])[0] data['entry'][entry] = encrypted save_data(data) print(f'\nEntry for {entry} created!')
def delete_entry(entry): data = load_data() if entry not in data['entry']: exit(f'\nCannot delete {entry} because it does not exist') message = (f'WARNING! You are about to delete your entry for {entry}!\n' f'If you are sure about this, please type "{entry}" to confirm') print(message) confirm = input('Confirm: ') if confirm == entry: del data['entry'][entry] save_data(data) print(f'\n{entry} deleted') else: print('\nBacking out...')
def refresh(self): self.data = load_data() columns = QGridLayout() top = QVBoxLayout() bottom = QVBoxLayout() for entry in self.data['entry']: self.entries.addItem(QListWidgetItem(entry)) top_label = QLabel('Entries') top.addWidget(top_label) top.addWidget(self.entries) top.addStretch(1) bottom_label = QLabel('Options') bottom.addWidget(bottom_label) bottom.addStretch(1) columns.addLayout(top, 0, 0) columns.addLayout(bottom, 1, 0) self.setLayout(columns)
def list_entries(): data = load_data() print('Entries:') for entry in data['entry'].keys(): print(entry)