int _tmain(int argc, _TCHAR* argv[])
{
char key[] = {0x0c,0x0a,0x13,0x09,0x0c,0x0b,0x0a,0x08};
int j = 0,r = 0;
char szUserName[51];
cout<<"Input The User Name:";
cin>>szUserName;
if (lstrlen(szUserName) < 5 )
{
cout<<"The Length of UserName must be greater than 4.\n";
system("pause");
return 1;;
}
for (int i = 3; i < lstrlen(szUserName); i ++)
{
if (j > 7) j = 0;
r = r + *(szUserName + i) * key[j];
j ++;
}
wsprintf(szUserName,"%ld",(unsigned int)r);
cout<<"The Serial Number is:";
cout<<szUserName;
cout<<"\nOk...\n";
system("pause");
return 0;
}
#include "stdafx.h"
#include "windows.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char key[] = {0x0c,0x0a,0x13,0x09,0x0c,0x0b,0x0a,0x08};
int j = 0;
UINT r = 0;
char szUserName[51];
cout<<"Input The User Name:";
cin>>szUserName;
if (lstrlen(szUserName) < 5 )
{
cout<<"The Length of UserName must be greater than 4.\n";
system("pause");
return 1;;
}
for (int i = 3; i < lstrlen(szUserName); i ++)
{
if (j > 7) j = 0;
r = r + (BYTE)*(szUserName + i) * key[j];
j ++;
}
wsprintf(szUserName,"%ld",(unsigned int)r);
cout<<"The Serial Number is:";
cout<<szUserName;
cout<<"\nOk...\n";
system("pause");
return 0;
}