def main(): args = parser.parse_args() vipe_path = which('vipe') if vipe_path is None: print("Error: cannot find 'vipe'", file=sys.stderr) return -1 raw_password = getpass() vipe_process = subprocess.Popen([vipe_path], stdin=subprocess.PIPE, stdout=subprocess.PIPE) if os.path.exists(args.filename): with open(args.filename, 'rb') as f: encrypted_text = enctext.decrypt(raw_password, f.read()) else: encrypted_text = None stdoutdata, _ = vipe_process.communicate(encrypted_text) if vipe_process.returncode == 0: with open(args.filename, 'wb') as f: f.write(enctext.encrypt(raw_password, stdoutdata)) else: print('Error: vipe failed; You must check the temporary directory') return vipe_process.returncode return 0
def main(): args = parser.parse_args() raw_password = getpass() if os.path.exists(args.filename): with open(args.filename, 'rb') as f: decrypted_string = enctext.decrypt(raw_password, f.read()) print(decrypted_string.decode('utf-8'), end="", flush=True) return 0
def main(): args = parser.parse_args() raw_password = getpass() if os.path.exists(args.filename): with open(args.filename, "rb") as f: decrypted_string = enctext.decrypt(raw_password, f.read()) print(decrypted_string.decode("utf-8"), end="", flush=True) return 0
def test_encrypto_and_decrypt(self): encrypted_text = enctext.encrypt(self.raw_password, self.raw_text) decrypted_text = enctext.decrypt(self.raw_password, encrypted_text) self.assertEqual(self.raw_text, decrypted_text)
def test_bad_password(self): encrypted_text = enctext.encrypt(self.raw_password, self.raw_text) decrypted_text = enctext.decrypt('wrong_password', encrypted_text) self.assertEqual(self.raw_text, decrypted_text)