通过机器码获得注册码的完整方案(转贴过来,留着看看)
想加密自己的软件,看过一些软件的作法,思路如下:
1、用户安装后,得出本机的机器码(硬盘的序列号,不想用网卡,因为很多机器没有网
卡)。生成机器码代码
2、用户将该机器码EMAIL给我,我用该机器码生成一个注册码,发送给用户。注册码生成
代码
3、用户在程序中输入该注册码,程序逆算该注册码,与机器码核对,查看是否相符。注册
码逆算、核对代码,
4、如果用户安装后没有得到注册码,在N天后部分功能不可用。不要太容易被改(虽然说
安装后也只有少部份功能能用)。时限功能代码,
zw84611 (2002-12-2 23:8)
function GetHDNumber(Drv : String): DWORD; //得到硬盘序列号
var
VolumeSerialNumber : DWORD;
MaximumComponentLength : DWORD;
FileSystemFlags : DWORD;
begin
if Drv[Length(Drv)] ='':'' then Drv := Drv + ''\'';
GetVolumeInformation(pChar(Drv),
nil,
0,
@VolumeSerialNumber,
MaximumComponentLength,
FileSystemFlags,
nil,
0);
Result:= (VolumeSerialNumber);
end;
function Serial(Num:DWORD):string; //这个号码是用户给你生成注册码的,它通过对硬盘序列号编码而来。
var sNum:string; inChar:array[1..4]of char;
begin
Num:=Num xor 8009211011;
sNum:=inttostr(Num);
inChar:=char(((integer(sNum)+integer(sNum))mod 5)+integer(''a''));
inChar:=char(((integer(sNum)+integer(sNum))mod 5)+integer(''a''));
inChar:=char(((integer(sNum)+integer(sNum))mod 5)+integer(''a''));
inChar:=char(((integer(sNum)+integer(sNum)+integer(sNum))mod 5)+integer(''a''));
insert(inChar,sNum,1);
insert(inChar,sNum,3);
insert(inChar,sNum,5);
insert(inChar,sNum,9);
Result:=sNum;
end;
function encode(License:string):string;
var str,sNum:string; number:dword; byte,byte1:array[1..4]of dword;
inChar:array[1..3]of char;
begin
str:=license;
delete(str,1,1);
delete(str,2,1);
delete(str,3,1);
delete(str,6,1);
number:=strtoint64(str);
number:=not number;
number:=number xor $1973122980;
byte:=(number and $0ff000000) shr 24;
byte:=(number and $0ff0000) shr 16;
byte:=(number and $0ff00) shr 8;
byte:=(number and $0ff);
byte1:=((byteand $0c0)+(byteand $0c0)shr 2)+((byteand $0c0)shr 4)+((byteand $0c0)shr 6);
byte1:=((byteand $30)shl 2)+(byteand $30)+((byteand $30)shr 2)+((byteand $30)shr 4);
byte1:=((byteand $0c)shl 4)+((byteand $0c)shl 2)+(byteand $0c)+((byteand $0c)shr 2);
byte1:=((byteand $03)shl 6)+((byteand $03)shl 4)+((byteand $03)shl 2)+(byteand $03);
number:=((byte1)shl 24)+((byte1)shl 16)
+((byte1)shl 8)+(byte1);
byte:=((number and $0ff000000)shr 24);//右移24位
byte:=((number and $0ff0000)shr 16);
byte:=((number and $0ff00)shr 8);
byte:=(number and $0ff);
byte:=(((byte and $f0))shr 4)+(((byte and $0f))shl 4);
byte:=(((byte and $f0))shr 4)+(((byte and $0f))shl 4);
byte:=(((byte and $f0))shr 4)+(((byte and $0f))shl 4);
byte:=(((byte and $f0))shr 4)+(((byte and $0f))shl 4);
number:=((byte)shl 24)+((byte)shl 16)
+((byte)shl 8)+(byte);
sNum:=inttostr(Number);
inChar:=char(((integer(sNum)+integer(sNum))mod 5)+integer(''a''));
inChar:=char(((integer(sNum)+integer(sNum))mod 5)+integer(''a''));
inChar:=char(((integer(sNum)+integer(sNum))mod 5)+integer(''a''));
insert(inChar,sNum,1);
insert(inChar,sNum,5);
insert(inChar,sNum,9);
result:=sNum;
end;
function decode(code:string):d