This method creates the key to decrypt the database.

def transform_key(startkey, seed_key, seed_rand, rounds):
    """
    This method creates the key to decrypt the database.
    """
    masterkey = startkey
    aes = AES.new(seed_key, AES.MODE_ECB)

    # Encrypt the created hash <rounds> times
    for _i in range(rounds):
        masterkey = aes.encrypt(masterkey)

    # Finally, hash it again...
    masterkey = hashlib.sha256(masterkey).digest()
    # ...and hash the result together with the randomseed
    return hashlib.sha256(seed_rand + masterkey).digest()