@classmethod<EOL><INDENT>def encrypt(cls, crypto, privkey, passphrase):<DEDENT>
pub_byte, priv_byte = get_magic_bytes(crypto)<EOL>privformat = get_privkey_format(privkey)<EOL>if privformat in ['<STR_LIT>','<STR_LIT>']:<EOL><INDENT>compressed = True<EOL>flagbyte = b'<STR_LIT>'<EOL>if privformat == '<STR_LIT>':<EOL><INDENT>privkey = encode_privkey(privkey, '<STR_LIT>')<EOL>privformat = get_privkey_format(privkey)<EOL><DEDENT><DEDENT>if privformat in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>compressed = False<EOL>flagbyte = b'<STR_LIT>'<EOL><DEDENT>if privformat == '<STR_LIT>':<EOL><INDENT>privkey = encode_privkey(privkey,'<STR_LIT>')<EOL>privformat = get_privkey_format(privkey)<EOL><DEDENT>pubkey = privtopub(privkey)<EOL>addr = pubtoaddr(pubkey, pub_byte)<EOL>passphrase = normalize('<STR_LIT>', unicode(passphrase))<EOL>if is_py2:<EOL><INDENT>ascii_key = addr<EOL>passphrase = passphrase.encode('<STR_LIT:utf8>')<EOL><DEDENT>else:<EOL><INDENT>ascii_key = bytes(addr,'<STR_LIT:ascii>')<EOL><DEDENT>salt = sha256(sha256(ascii_key).digest()).digest()[<NUM_LIT:0>:<NUM_LIT:4>]<EOL>key = scrypt.hash(passphrase, salt, <NUM_LIT>, <NUM_LIT:8>, <NUM_LIT:8>)<EOL>derivedhalf1, derivedhalf2 = key[:<NUM_LIT:32>], key[<NUM_LIT:32>:]<EOL>aes = AES.new(derivedhalf2)<EOL>encryptedhalf1 = aes.encrypt(unhexlify('<STR_LIT>' % (long(privkey[<NUM_LIT:0>:<NUM_LIT:32>], <NUM_LIT:16>) ^ long(hexlify(derivedhalf1[<NUM_LIT:0>:<NUM_LIT:16>]), <NUM_LIT:16>))))<EOL>encryptedhalf2 = aes.encrypt(unhexlify('<STR_LIT>' % (long(privkey[<NUM_LIT:32>:<NUM_LIT:64>], <NUM_LIT:16>) ^ long(hexlify(derivedhalf1[<NUM_LIT:16>:<NUM_LIT:32>]), <NUM_LIT:16>))))<EOL>payload = b'<STR_LIT>' + flagbyte + salt + encryptedhalf1 + encryptedhalf2<EOL>return cls(crypto, b58encode_check(payload))<EOL>
BIP0038 non-ec-multiply encryption. Returns BIP0038 encrypted privkey.