def decrypt(self): # 2 questions = [ { 'type': 'input', 'name': 'cipher_text', 'message': 'Input encrypted cipher text:', } ] input_password = [ { 'type': 'password', 'name': 'password', 'message': 'Enter the password of private key to decrypt:', } ] answer = prompt(questions) crypto = CryptoUtility(self.key_path) if not crypto.password: input_pwd = prompt(input_password) crypto.password = input_pwd['password'] print(f' Decrypting...', end="\r") crypto.import_private_key_from_file() password = crypto.decrypt_text(answer['cipher_text']) qprint(f'Your password is:', style='#06c8ff', flush=True) qprint(f'\n{password}\n', style='bold #06c8ff')
def decrypt(self): # 2 questions = [{ 'type': 'input', 'name': 'cipher_text', 'message': 'Input encrypted cipher text:', }] input_password = [{ 'type': 'password', 'name': 'password', 'message': 'Enter the password to decrypt' }] answer = prompt(questions, style=self.style) crypto = CryptoUtility() if not crypto.password: input_pwd = prompt(input_password, style=self.style) crypto.password = input_pwd['password'] crypto.import_private_key_from_file() password = crypto.decrypt_text(answer['cipher_text']) print(f'Your password is: {password}') print() self.main_menu()
def save_private_key_password(self): # 3.1.5 input_password = [ { 'type': 'password', 'name': 'password', 'message': 'Enter the password to decrypt private key:', } ] crypto = CryptoUtility(self.key_path) if not crypto.password: input_pwd = prompt(input_password) crypto.password = input_pwd['password'] if crypto.import_private_key_from_file(): crypto.export_password_hash_to_file() print('Saved password successfully!') else: print('Wrong Password!') else: print('Password already saved.') self.configure_key_pair()