def get_password(choice): """Assigns the user passwords according to choice.""" global password if choice == "prompt": i = raw_input("Use a password? <Y/n> ").lower() if not i.startswith("n"): choice = "yes" if choice == "yes": password = backend.stretch_key(getpass.getpass("Password: "******"\n", else: # We will reach this point if the user has chosen not to use # a password or if input was bogus -- so, assign password to # an empty string. password = ""
def test_key_stretch(self): self.assertEqual(backend.stretch_key("test 1")[:5], "\xa2\x89\x90\xdbQ") self.assertEqual(backend.stretch_key("test 2")[:5], "\x07\x88\xa4\xbbz") self.assertEqual(backend.stretch_key("test 3")[:5], "Q\xdb\xcb\x1e\x98")