www.pudn.com > 20080413_ClockSystem.rar > Crypt.cpp
// Crypt.cpp: implementation of the CCrypt class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Attendance.h"
#include "Crypt.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
// 常量
#define C1 52845
#define C2 22719
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCrypt::CCrypt()
{
}
CCrypt::~CCrypt()
{
}
CString CCrypt::Encrypt(CString S, WORD Key) // 加密函数
{
CString Result,str;
int i,j;
Result=S; // 初始化结果字符串
for(i=0; i>8)); // 将密钥移位后与字符异或
Key = ((BYTE)Result.GetAt(i)+Key)*C1+C2; // 产生下一个密钥
}
S=Result; // 保存结果
Result.Empty(); // 清除结果
for(i=0; i>8)); // 将密钥移位后与字符异或
Key = ((BYTE)S.GetAt(i)+Key)*C1+C2; // 产生下一个密钥
}
return Result;
}