像那些付費軟體的註冊演算法一般是用什麼演算法? VCL組件開發及應用
http://www.delphi2007.net/DelphiVCL/html/delphi_20061224100656157.html
像那些付費軟體的註冊演算法一般是用什麼演算法?如果我想給我的軟體加密,使用那種演算法比較好?前輩們給點意見啊
//轉貼
DELPHI程式註冊碼設計
當你辛辛苦苦用DELPHI做好了一個你認為十分不錯的程式,你是否想把它發布出去成為共用軟體呢? 做為一個共用軟體,註冊碼肯定是少不了的,你可以通過判斷程式是否註冊來進行功能,時間或一些其它限制.現在就介紹一種簡單的註冊碼製造方法.思路是這樣的:程式運行時先檢測註冊表,如果找到註冊項,則表明已經註冊,如果沒有找到註冊項,則提示要求註冊.
<註冊常式>
在DELPHI下建立一工程,放置Edit1,Edit2,Label1,Label2,Button1組件.具體代碼如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Registry;//在此加上Registry以便調用註冊表.
type
TForm1 = class(Tform)
Button1: Tbutton;
Edit1: Tedit;
Edit2: Tedit;
Label1: Tlabel;
Label2: Tlabel;
procedure Button1Click(Sender: Tobject);
procedure FormCreate(Sender: Tobject);
private
Function Check():Boolean;
Procedure CheckReg();
Procedure CreateReg();
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Pname:string; //全域變數,存放使用者名稱和註冊碼.
Ppass:integer;
implementation
{$R *.DFM}
Procedure TForm1.CreateReg();//建立使用者資訊.
var Rego:Tregistry;
begin
Rego:=Tregistry.Create;
Rego.RootKey:=HKEY_USERS;
rego.OpenKey('.DEFAULT\Software\AngelSoft\Demo',True);//鍵名為AngelSoft\Demo,可自行修改.
Rego.WriteString('Name',Pname);//寫入使用者名稱.
Rego.WriteInteger('Pass',Ppass);//寫入註冊碼.
Rego.Free;
ShowMessage('程式已經註冊,謝謝!');
CheckReg; //重新整理.
end;
Procedure TForm1.CheckReg();//檢查程式是否在註冊表中註冊.
var Rego:Tregistry;
begin
Rego:=Tregistry.Create;
Rego.RootKey:=HKEY_USERS;
IF Rego.OpenKey('.DEFAULT\Software\AngelSoft\Demo',False) then
begin
Form1.Caption:='軟體已經註冊';
Button1.Enabled:=false;
Label1.Caption:=rego.ReadString('Name');//讀使用者名稱.
Label2.Caption:=IntToStr(Rego.ReadInteger('Pass')); //讀註冊碼.
rego.Free;
end
else Form1.Caption:='軟體未註冊,請註冊';
end;
Function TForm1.Check():Boolean;//檢查註冊碼是否正確.
var
Temp:pchar;
Name:string;
c:char;
I,Long,Pass:integer;
begin
Pass:=0;
Name:=edit1.Text;
long:=length(Name);
for I:=1 to Long do
begin
temp:=pchar(copy(Name,I,1));
c:=temp^;
Pass:=Pass+ord(c); //將使用者名稱每個字元轉換為ASCII碼後相加.
end;
if StrToInt(Edit2.Text)=pass then
begin
Result:=True;
Pname:=Name;
Ppass:=Pass;
end
else Result:=False;
end;
procedure TForm1.Button1Click(Sender: Tobject);
begin
if Check then CreateReg
else ShowMessage('註冊碼不正確,無法註冊');
end;
procedure TForm1.FormCreate(Sender: Tobject);
begin
CheckReg;
end;
end.
<註冊器>
在DELPHI下建立一工程,放置Edit1,Edit2,Button1組件.具體代碼如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(Tform)
Button1: Tbutton;
Edit1: Tedit;
Edit2: Tedit;
procedure Button1Click(Sender: Tobject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: Tobject);
var
Temp:pchar;
Name:string;
c:char;
I,Long,Pass:integer;
begin
Pass:=0;
Name:=edit1.Text;
long:=length(Name);
for I:=1 to Long do
begin
temp:=pchar(copy(Name,I,1));
c:=temp^;
Pass:=Pass+ord(c);
end;
edit2.text:=IntToStr(pass);
end;
end.
從<註冊器>中取得註冊碼,便可在<註冊常式>中進行註冊.原理是使用ORD函數取得使用者名稱每單個字元的ASCII碼值,並進行相加得到註冊碼.當然,這十分容易並破解,你可以用XOR進行異或操作,或者倒取反值...具體的要看你怎麼實現了.總之,本文章只拋磚引玉罷了.
也可以用專門的控制項來做
Regware
破解只是時間和興趣的問題
軟體沒有寫成功之前考慮加密是白搭
一個寫的差的軟體就是開源給別人都沒人用
加密之前提起別人破解的興趣先
爛軟體不加密也沒人用,好軟體加密了照樣破!
WinRAR加密足夠牛了吧,有幾個軟體可以做到這個程度的?還不照樣被幹掉
共用軟體作者還是提高自己的軟體先,別尚未成功就開始防破解,精力用錯地方了。
找到的一個:
給你一個,不過是檢測註冊表中的值進行判斷是否已經註冊:
當然這程式中的註冊碼是隨便寫的...
procedure TE_Mainf.FormCreate(Sender: TObject);
var re_id: integer;
registerTemp: TRegistry;
inputstr,get_id: string;
dy, clickedok: boolean;
i: double;
label Y, N;
begin
dy := false;//軟體是否已到註冊期、及是否允許繼續使用的標誌,當值為FALSE是為允許使用
registerTemp := TRegistry.Create; //準備使用註冊表
with registerTemp do
begin
RootKey := HKEY_LOCAL_MACHINE; //存放在此根下
if OpenKey('Software\Microsoft\Windows\CurrentVersion\Mark', True) then // 建一目錄,存放標誌值。當然也可以存放在已存在的目錄下。
begin
if valueexists('gc_id') then //用gc_id的值作為標誌,首先判斷其存在否
begin
re_id := readinteger('gc_id'); //讀出標誌值
if (re_id <> 0) and (re_id <> 100) then //若標誌值為0,則說明登入 ,若不為0且值不到100,說明雖未註冊,但允許使用的次數尚未達到。
begin
re_id := re_id + 5; //允許標誌的最大值為100,每次加5,則最多隻可用20次
writeinteger('gc_id', re_id); //將更新後的標誌值寫入註冊表中
i := (100 - re_id) / 5;
if application.MessageBox(PAnsiChar('您使用的軟體沒有註冊,還有 ' + floattostr(i) + ' 次使用次數,現在要註冊嗎?'), '提示資訊', mb_yesno + mb_iconwarning) = idyes then
begin
if i = 0 then
application.Terminate
else
goto y;
end;
end;
if re_id = 0 then goto N;
if re_id = 100 then dy := true; //若標誌值已達到100,則應當註冊
end
else
Writeinteger('gc_id', 5); //建立標誌,共置初始標誌值
re_id := readinteger('gc_id');
i := (100 - re_id) / 5;
if Application.MessageBox(PAnsiChar('您使用的軟體沒有註冊,還有 ' + floattostr(i) + ' 次使用次數,現在要註冊嗎?'), '提示資訊', mb_yesno + mb_iconwarning) = idyes then
begin
if i = 0 then
application.Terminate
else
goto Y;
end;
end;
if dy then
Y: begin //若dy值為TRUE,則應提示使用者輸入註冊碼,進行註冊
clickedok := InputQuery('系統提示', '請輸入註冊碼:', inputstr);
if clickedok then
begin
get_id := inttostr(83392582 * 2); //註冊碼為166785164,夠簡單的......
if get_id = inputstr then
begin
Writeinteger('gc_id', 0); //若輸入的註冊碼正確,則將標誌值置為0,即登入
Application.MessageBox('恭喜你,軟體註冊成功!', '提示', MB_OK);
CloseKey;
Free;
end
else
begin
application.messagebox('註冊碼錯誤!請與作者聯絡!', '警告', mb_ok + mb_iconstop);
CloseKey;
Free;
application.terminate; //中止程式運行,拒絕讓其繼續使用
end;
end
else
begin
CloseKey;
Free;
application.terminate; //中止程式運行,拒絕讓其繼續使用
end;
end;
end;
N: datamodule1 := tdatamodule1.Create(self);
if not assigned(E_loginf) then
E_loginf := tE_loginf.Create(self);
E_loginf.ShowModal;
if E_loginf.ModalResult = mrCancel then//檢查返回模式,如果是關閉或是取消,則中止運行
begin
Application.Terminate;
exit;
end;
不知有沒達到你要求~~
樓主,好像這個問題沒固定的答案.
每個人都可以想個演算法.
同意4星
呵呵,還有硬體加密狗可以加密的.
演算法自然越私人越好了
不然別人直接根據公開演算法就算出來,你的加密就沒啥意義了