def encrypt(privkey, passphrase):
if isinstance(privkey, str):<EOL><INDENT>privkey = PrivateKey(privkey)<EOL><DEDENT>else:<EOL><INDENT>privkey = PrivateKey(repr(privkey))<EOL><DEDENT>privkeyhex = repr(privkey)  <EOL>addr = format(privkey.bitcoin.address, "<STR_LIT>")<EOL>a = _bytes(addr)<EOL>salt = hashlib.sha256(hashlib.sha256(a).digest()).digest()[<NUM_LIT:0>:<NUM_LIT:4>]<EOL>if SCRYPT_MODULE == "<STR_LIT>":  <EOL><INDENT>key = scrypt.hash(passphrase, salt, <NUM_LIT>, <NUM_LIT:8>, <NUM_LIT:8>)<EOL><DEDENT>elif SCRYPT_MODULE == "<STR_LIT>":  <EOL><INDENT>key = scrypt.scrypt(bytes(passphrase, "<STR_LIT:utf-8>"), salt, <NUM_LIT>, <NUM_LIT:8>, <NUM_LIT:8>)<EOL><DEDENT>else:  <EOL><INDENT>raise ValueError("<STR_LIT>")  <EOL><DEDENT>(derived_half1, derived_half2) = (key[:<NUM_LIT:32>], key[<NUM_LIT:32>:])<EOL>aes = AES.new(derived_half2, AES.MODE_ECB)<EOL>encrypted_half1 = _encrypt_xor(privkeyhex[:<NUM_LIT:32>], derived_half1[:<NUM_LIT:16>], aes)<EOL>encrypted_half2 = _encrypt_xor(privkeyhex[<NUM_LIT:32>:], derived_half1[<NUM_LIT:16>:], aes)<EOL>"<STR_LIT>"<EOL>payload = b"<STR_LIT>" + b"<STR_LIT>" + b"<STR_LIT>" + salt + encrypted_half1 + encrypted_half2<EOL>"<STR_LIT>"<EOL>checksum = hashlib.sha256(hashlib.sha256(payload).digest()).digest()[:<NUM_LIT:4>]<EOL>privatkey = hexlify(payload + checksum).decode("<STR_LIT:ascii>")<EOL>return Base58(privatkey)<EOL>
BIP0038 non-ec-multiply encryption. Returns BIP0038 encrypted privkey.

    :param privkey: Private key
    :type privkey: Base58
    :param str passphrase: UTF-8 encoded passphrase for encryption
    :return: BIP0038 non-ec-multiply encrypted wif key
    :rtype: Base58