help to convert c++ fonction in python
Tim Roberts
timr at probo.com
Sat Oct 17 18:09:08 EDT 2009
Toff <christophedeze at gmail.com> wrote:
>
>I'm trying to convert 2 c++ functions in python
>
>they come from wpkg client
>https://wpkg.svn.sourceforge.net/svnroot/wpkg/wpkg-client/Sources/Components/XmlSettings.cpp
>
>they are
>CString CXmlSettings::Crypt(CString str)
>CString CXmlSettings::Decrypt(CString str)
>
>CAn someone help me?
>i d'ont know much about c++
It's possible this solution is a bit too clever.
import base64
import itertools
key = (
0x50, 0xF7, 0x82, 0x69, 0xEA, 0x2D, 0xDD, 0x2D, 0x6A, 0xB4,
0x33, 0x8F, 0xD5, 0xC7, 0x90, 0x9C, 0x22, 0x95, 0x61, 0xE5,
0x65, 0xF6, 0xB0, 0x4B, 0x94, 0x47, 0xB0, 0xBD, 0x73, 0x58,
0x56, 0x87, 0x79, 0x7B, 0xE6, 0xB0, 0xD2, 0x20, 0x28, 0xE1
)
def Crypt( s ):
return base64.encode(
''.join(
chr(ord(x)^y) for x,y in itertools.izip(s,itertools.cycle(key))
)
)
def Decrypt( s )
s1 = base64.decode( s )
return ''.join(
chr(ord(x)^y) for x,y in itertools.izip(s1,itertools.cycle(key))
)
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list