Exemplo n.º 1
0
 def test_non_cp1252_compatible_chars_replaced(self):
     self.assertEqual(encode_password(u"\u2713"), b'?')
     # And to show you how terrible keepass's encoding
     # is:
     self.assertEqual(encode_password(u"\u2714"), b'?')
     # Or in other words:
     self.assertEqual(encode_password(u"\u2714"),
                      encode_password(u"\u2713"))
Exemplo n.º 2
0
def create_db(args):
    if 'KP_INSECURE_PASSWORD' in os.environ:
        # This env var is really intended for testing purposes.
        # No one should be using this var.
        password = os.environ['KP_INSECURE_PASSWORD']
    elif args.stdin:
        password = sys.stdin.read()
    else:
        password = getpass.getpass('Password: '******'s ok if no key file
        # was specified.
        key_file_contents = None
    db = Database(db_file.read(), password=password,
                  key_file_contents=key_file_contents)
    return db
Exemplo n.º 3
0
def create_db(args):
    if 'KP_INSECURE_PASSWORD' in os.environ:
        # This env var is really intended for testing purposes.
        # No one should be using this var.
        password = os.environ['KP_INSECURE_PASSWORD']
    elif args.stdin:
        password = sys.stdin.read()
    else:
        password = getpass.getpass('Password: '******'s ok if no key file
        # was specified.
        key_file_contents = None
    db = Database(db_file.read(),
                  password=password,
                  key_file_contents=key_file_contents)
    return db
Exemplo n.º 4
0
 def test_encode_cp1252_compatible_chars(self):
     self.assertEqual(encode_password(u"\u00f6"), b'\xf6')
Exemplo n.º 5
0
 def test_encode_ascii(self):
     self.assertEqual(encode_password('foo'), b'foo')
Exemplo n.º 6
0
 def test_master_password_unicode(self):
     kdb_contents = open_data_file('password-unicode.kdb').read()
     db = Database(kdb_contents, encode_password(u'password\u2713'))
     # Verify we can read anything from the db.
     self.assertEqual(len(db.groups), 2)
Exemplo n.º 7
0
 def test_master_password_latin1(self):
     password = u"\u00f6\u00e4\u00fc\u00df"
     kdb_contents = open_data_file('password-latin1.kdb').read()
     db = Database(kdb_contents, encode_password(password))
     self.assertEqual(len(db.groups), 2)