主题:将一下C代码专为C#代码
unsigned short int CCSUDPage::UpdatePassWord(unsigned short int MasterNo,BYTE *mDate,BYTE *aDate,BYTE *fDate)
{
char TmpBuf[20];
unsigned short int Year;
unsigned short int Month;
unsigned short int Day;
unsigned short int mYear;
unsigned short int mMonth;
unsigned short int mDay;
unsigned short int aYear;
unsigned short int aMonth;
unsigned short int aDay;
unsigned short int fYear;
unsigned short int fMonth;
unsigned short int fDay;
union{
unsigned short int u1;
BYTE ch[2];
}uc;
BYTE b0;
BYTE b1;
//mDate 2008/02/14 日期的存储格式可能是这样
//主机系统制造日期
/*
memmove(TmpBuf,mDate,4);
TmpBuf[4] = 0 ;
mYear = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,mDate+5,2);
TmpBuf[2] = 0 ;
mMonth = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,mDate+8,2);
TmpBuf[2] = 0 ;
mDay = (unsigned short int)atoi(TmpBuf);
*/
/*
//应用程序制造日期
memmove(TmpBuf,aDate,4);
TmpBuf[4] = 0 ;
aYear = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,aDate+5,2);
TmpBuf[2] = 0 ;
aMonth = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,aDate+8,2);
TmpBuf[2] = 0 ;
aDay = (unsigned short int)atoi(TmpBuf);
//
*/
//
mYear=2009;
mMonth=9;
mDay=10;
//
aYear=2009;
aMonth=9;
aDay=10;
//
//升级文件制造日期
memmove(TmpBuf,fDate,4);
TmpBuf[4] = 0 ;
fYear = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,fDate+5,2);
TmpBuf[2] = 0 ;
fMonth = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,fDate+8,2);
TmpBuf[2] = 0 ;
fDay = (unsigned short int)atoi(TmpBuf);
/*
Year = mYear+~aYear+fYear^0X7+fMonth+mDay^1+aDay^2+fDay^3; // For V2.2 password
Month = mMonth^0XE0+aMonth+aDay+fDay+3;
Day = aYear+aMonth^5+fMonth+mDay^9+aDay^7+fDay^5+5;
*/
//Year=mYear+aYear取反+fYear异或0xA5+fMonth+mDay异或1+aDay异或2+fDay异或3
Year = mYear+~aYear+fYear^0XA5+fMonth+mDay^1+aDay^2+fDay^3; // For V2.3 password
//Month=mMonth异或0xC0+aMonth+aDay+fDay+3;
Month = mMonth^0XC0+aMonth+aDay+fDay+3;
//Day=aYear+aMonth异或5+fMonth+mDay异或9+aDay异或7+fDay异或5+3
Day = aYear+aMonth^5+fMonth+mDay^9+aDay^7+fDay^5+3;
//使用联合体,把short int存放到两个char变量中去
uc.u1 = (unsigned short int)(Year+3*Month+5*Day+11);
b0 = uc.ch[1];
b1 = uc.ch[0];
uc.u1 = (unsigned short int)MasterNo;
uc.ch[1] ^= (BYTE)(b1*uc.ch[0]);
uc.ch[0] = (b0^uc.ch[1]);
//返回联合体中的内容
return uc.u1;
}
unsigned short int CCSUDPage::UpdatePassWord(unsigned short int MasterNo,BYTE *mDate,BYTE *aDate,BYTE *fDate)
输入参数
MasterNo:主机号,需要根据用户名来确定,前提条件为用户已经根据主机号注册了用户名
mDate:主机系统制造日期,功能已经去掉了在程序里边规定了日期为2009/09/10
aDate:应用程序制造日期,功能已经去掉了在程序里边规定了日期为2009/09/10
fDate:生计文件制造日期,改功能需要用户在界面上输入最终生成的为字符串"2009/02/14"格式,存放在fDate指针所制向的BYTE数组下
如:byteArray[0]='2';
byteArray[1]='0';
byteArray[2]='0';
byteArray[3]='9';
byteArray[4]='/';
byteArray[5]='0';
byteArray[6]='2';
byteArray[7]='/';
byteArray[8]='1';
byteArray[9]='4';
返回的数值为 unsigned short int 的密码
------------------
效果就是要得到密码:
主机号 主机系统制造日期 应用程序制造日期 升级文件制造日期 密码
35765 2007-11-27 2009-2-13 2009-9-11 00304
51507 2007-11-26 2009-6-5 2009-5-8 53987
54241 2009-5-26 2009-6-26 2009-9-11 09236
{
char TmpBuf[20];
unsigned short int Year;
unsigned short int Month;
unsigned short int Day;
unsigned short int mYear;
unsigned short int mMonth;
unsigned short int mDay;
unsigned short int aYear;
unsigned short int aMonth;
unsigned short int aDay;
unsigned short int fYear;
unsigned short int fMonth;
unsigned short int fDay;
union{
unsigned short int u1;
BYTE ch[2];
}uc;
BYTE b0;
BYTE b1;
//mDate 2008/02/14 日期的存储格式可能是这样
//主机系统制造日期
/*
memmove(TmpBuf,mDate,4);
TmpBuf[4] = 0 ;
mYear = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,mDate+5,2);
TmpBuf[2] = 0 ;
mMonth = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,mDate+8,2);
TmpBuf[2] = 0 ;
mDay = (unsigned short int)atoi(TmpBuf);
*/
/*
//应用程序制造日期
memmove(TmpBuf,aDate,4);
TmpBuf[4] = 0 ;
aYear = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,aDate+5,2);
TmpBuf[2] = 0 ;
aMonth = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,aDate+8,2);
TmpBuf[2] = 0 ;
aDay = (unsigned short int)atoi(TmpBuf);
//
*/
//
mYear=2009;
mMonth=9;
mDay=10;
//
aYear=2009;
aMonth=9;
aDay=10;
//
//升级文件制造日期
memmove(TmpBuf,fDate,4);
TmpBuf[4] = 0 ;
fYear = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,fDate+5,2);
TmpBuf[2] = 0 ;
fMonth = (unsigned short int)atoi(TmpBuf);
memmove(TmpBuf,fDate+8,2);
TmpBuf[2] = 0 ;
fDay = (unsigned short int)atoi(TmpBuf);
/*
Year = mYear+~aYear+fYear^0X7+fMonth+mDay^1+aDay^2+fDay^3; // For V2.2 password
Month = mMonth^0XE0+aMonth+aDay+fDay+3;
Day = aYear+aMonth^5+fMonth+mDay^9+aDay^7+fDay^5+5;
*/
//Year=mYear+aYear取反+fYear异或0xA5+fMonth+mDay异或1+aDay异或2+fDay异或3
Year = mYear+~aYear+fYear^0XA5+fMonth+mDay^1+aDay^2+fDay^3; // For V2.3 password
//Month=mMonth异或0xC0+aMonth+aDay+fDay+3;
Month = mMonth^0XC0+aMonth+aDay+fDay+3;
//Day=aYear+aMonth异或5+fMonth+mDay异或9+aDay异或7+fDay异或5+3
Day = aYear+aMonth^5+fMonth+mDay^9+aDay^7+fDay^5+3;
//使用联合体,把short int存放到两个char变量中去
uc.u1 = (unsigned short int)(Year+3*Month+5*Day+11);
b0 = uc.ch[1];
b1 = uc.ch[0];
uc.u1 = (unsigned short int)MasterNo;
uc.ch[1] ^= (BYTE)(b1*uc.ch[0]);
uc.ch[0] = (b0^uc.ch[1]);
//返回联合体中的内容
return uc.u1;
}
unsigned short int CCSUDPage::UpdatePassWord(unsigned short int MasterNo,BYTE *mDate,BYTE *aDate,BYTE *fDate)
输入参数
MasterNo:主机号,需要根据用户名来确定,前提条件为用户已经根据主机号注册了用户名
mDate:主机系统制造日期,功能已经去掉了在程序里边规定了日期为2009/09/10
aDate:应用程序制造日期,功能已经去掉了在程序里边规定了日期为2009/09/10
fDate:生计文件制造日期,改功能需要用户在界面上输入最终生成的为字符串"2009/02/14"格式,存放在fDate指针所制向的BYTE数组下
如:byteArray[0]='2';
byteArray[1]='0';
byteArray[2]='0';
byteArray[3]='9';
byteArray[4]='/';
byteArray[5]='0';
byteArray[6]='2';
byteArray[7]='/';
byteArray[8]='1';
byteArray[9]='4';
返回的数值为 unsigned short int 的密码
------------------
效果就是要得到密码:
主机号 主机系统制造日期 应用程序制造日期 升级文件制造日期 密码
35765 2007-11-27 2009-2-13 2009-9-11 00304
51507 2007-11-26 2009-6-5 2009-5-8 53987
54241 2009-5-26 2009-6-26 2009-9-11 09236