def encrypt(cls, crypto, privkey, passphrase):
        """
        BIP0038 non-ec-multiply encryption. Returns BIP0038 encrypted privkey.
        """
        pub_byte, priv_byte = get_magic_bytes(crypto)
        privformat = get_privkey_format(privkey)
        if privformat in ['wif_compressed','hex_compressed']:
            compressed = True
            flagbyte = b'\xe0'
            if privformat == 'wif_compressed':
                privkey = encode_privkey(privkey, 'hex_compressed')
                privformat = get_privkey_format(privkey)
        if privformat in ['wif', 'hex']:
            compressed = False
            flagbyte = b'\xc0'
        if privformat == 'wif':
            privkey = encode_privkey(privkey,'hex')
            privformat = get_privkey_format(privkey)

        pubkey = privtopub(privkey)
        addr = pubtoaddr(pubkey, pub_byte)

        passphrase = normalize('NFC', unicode(passphrase))
        if is_py2:
            ascii_key = addr
            passphrase = passphrase.encode('utf8')
        else:
            ascii_key = bytes(addr,'ascii')

        salt = sha256(sha256(ascii_key).digest()).digest()[0:4]
        key = scrypt.hash(passphrase, salt, 16384, 8, 8)
        derivedhalf1, derivedhalf2 = key[:32], key[32:]

        aes = AES.new(derivedhalf2)
        encryptedhalf1 = aes.encrypt(unhexlify('%0.32x' % (long(privkey[0:32], 16) ^ long(hexlify(derivedhalf1[0:16]), 16))))
        encryptedhalf2 = aes.encrypt(unhexlify('%0.32x' % (long(privkey[32:64], 16) ^ long(hexlify(derivedhalf1[16:32]), 16))))

        # 39 bytes    2 (6P)      1(R/Y)    4          16               16
        payload = b'\x01\x42' + flagbyte + salt + encryptedhalf1 + encryptedhalf2
        return cls(crypto, b58encode_check(payload))
BIP0038 non-ec-multiply encryption. Returns BIP0038 encrypted privkey.