import hashlib


def PBEWithMD5AndDES_derivation(password, salt, iterations):
    """Compute a key and iv from a password and salt according to PBEWithMD5AndDES"""
    assert len(salt) == 8
    last_value = password.encode('ascii') + salt
    for _ in range(iterations):
        last_value = hashlib.md5(last_value).digest()
    assert len(last_value) == 16
    key = last_value[:8]
    iv = last_value[8:]
    return key, iv