|
#include "stdafx.h"
#include "Crypt.h"
const INT C1 = 52845;
const INT C2 = 22719;
const INT KEY = 72957;
//------------------------------------------------------------------------
BOOL CCrypt::Encrypt(BYTE *source, BYTE *destination, DWORD length)
{
DWORD i;
INT Key = KEY;
if (!source || !destination || length <= 0)
return FALSE;
for (i=0;i<length;i++)
{
//------------------------------------------------------------------------
destination[i] = source[i]^Key >> 8; //key 값을 제곱한뒤 8비트 밀어 줍니다..
//------------------------------------------------------------------------
Key = (destination[i] + Key) * C1 + C2;
}
return TRUE;
}
//------------------------------------------------------------------------
BOOL CCrypt::Decrypt(BYTE *source, BYTE *destination, DWORD length)
{
DWORD i;
BYTE PreviousBlock;
INT Key = KEY;
if (!source || !destination || length <= 0)
return FALSE;
for (i=0;i<length;i++)
{
PreviousBlock = source[i];
destination[i] = source[i]^Key >> 8;
Key = (PreviousBlock + Key) * C1 + C2;
}
return TRUE;
}
//------------------------------------------------------------------------
8비트 밀어 준다는게 무슨 뜻인지 모르겠습니다..
다시 말하자면
>> 연산자가 무엇을 하는지 모르겠습니다.
제 짧은 소견으로는 암호화의 루틴을 완전하게 거꿀로 연산하는게 복호화가 아닌가 싶은데
위의 소스에서는 복호화가 암호화의 반대로 하고 있는건가여?????????
아님 제가 복호화라는거에 대해 잘못 생각하고 있는건가여?????????
꼭 암호화나 복호화나 거의 비슷한 루틴같아서 질문드립니다..
|