<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def jks_pkey_encrypt(key, password_str):
 """ Encrypts the private key with password protection algorithm used by JKS keystores. """

    password_bytes = password_str.encode('utf-16be') # Java chars are UTF-16BE code units
    iv = os.urandom(20)

    key = bytearray(key)
    xoring = zip(key, _jks_keystream(iv, password_bytes))
    data = bytearray([d^k for d,k in xoring])

    check = hashlib.sha1(bytes(password_bytes + key)).digest()
    return bytes(iv + data + check)