I am trying to work out the encryption function to the following decryption function.
I see that the decrpt key is the first for bytes of Buf and that only 32 bytes are decrypted.Code:char* buf; unsigned int nKey = buf[3] << 24; nKey |= buf[2] << 16; nKey |= buf[1] << 8; nKey |= buf[0]; unsigned int nIndex = 4; for(unsigned int nBitNr = 0; nBitNr < 32; ++nBitNr, nIndex++) { int nDecryptBit = (nKey & (1 << nBitNr)) >> nBitNr; int chEncryptedByte = buf[nIndex]; int chDecryptedByte = chEncryptedByte; chDecryptedByte = chDecryptedByte ^ nDecryptBit; chDecryptedByte = chDecryptedByte & 1; chDecryptedByte = chDecryptedByte ^ chEncryptedByte; buf[nIndex] = chDecryptedByte; if(nBitNr == 31) break; } printf("File Decrypted is %s\n",buf);
From searching these forums I now know that
a = b ^ c goes to c = b ^ a
would a = b & 1 go to a = b & 0?
also what is this doing?Code:int nDecryptBit = (nKey & (1 << nBitNr)) >> nBitNr;



LinkBack URL
About LinkBacks


