// bCrypt = FALSE .. Dekryptuj text
// bCrypt = TRUE .. Zakryptuj text
CString CCrypt::Koduj(CString strText, BOOL bCrypt)
{
#define KODUJ_ROZSAH 256 - ' ' // 128-' ' // OK, ale nerobi diakriticke znaky
CString strOut = strText;
INT znak;
unsigned char *ptrkod, kodx;
unsigned char *kod = (unsigned char*)strKodStr.GetBuffer();
unsigned char *instr = (unsigned char*)strText.GetBuffer();
unsigned char *outstr = (unsigned char*)strOut.GetBuffer();
unsigned char oldznak = 0x71;
for (ptrkod = kod; *instr; ptrkod++,instr++,outstr++)
{
if (*instr<' ') znak = *instr;
else
{
kodx = *ptrkod;
if (!kodx) { ptrkod = kod; kodx = *ptrkod; }
kodx ^= (oldznak<<3) ^ (oldznak>>2) ^ 0x3a;
if (bCrypt)
{
znak = (int)*instr - ' ' + kodx;
while (znak >= KODUJ_ROZSAH) znak -= KODUJ_ROZSAH;
znak += ' ';
oldznak = (char)znak;
}
else
{
znak = (int)*instr - ' ' - kodx;
while (znak < 0) znak += KODUJ_ROZSAH;
znak += ' ';
oldznak = *instr;
}
}
*outstr = (unsigned char)znak;
}
return strOut;
}
syntax C++ je pre mňa španielska dedina ... vedel by mi niekto vysvetliť funkciu? prípadne skonvertovať?