1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| CString CrypterChaine(CString S)
{
int data[] = {1,8,67,8,22},
j=0,
ln = S.GetLength(),
i;
CString csCrypt;
for(i=0; i<ln; i++)
{
csCrypt.AppendFormat("%02X", (data[j] + (int)(unsigned char)S[i])%0xFF);
j++;
if (j==5) j=0;
}
return csCrypt;
}
CString DecrypterChaine(CString csCrypt)
{
int data[] = {1,8,67,8,22},
i,
j=0;
CString f, S;
while (csCrypt.GetLength()>1)
{
f = csCrypt[0];
f += csCrypt[1];
csCrypt.Delete(0,2);
i = strtoul( f, NULL, 16 );
i-=data[j];
if (i<=0) i+=255;
S.AppendFormat("%c",i);
j++;
if (j==5) j=0;
}
return S;
} |
Partager