unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp, IdBaseComponent, IdComponent, IdIPWatch;
type
TRC4Context =
record
D:
array[Byte]
of Byte;
I,J: Byte;
end;
TForm1 =
class(TForm)
Label1: TLabel;
ServerIP: TEdit;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
servmessage: TMemo;
Label4: TLabel;
ClientSocket1: TClientSocket;
ListBox1: TListBox;
Label5: TLabel;
kennung: TEdit;
Label3: TLabel;
pass: TEdit;
servpass: TEdit;
Label6: TLabel;
IdIPWatch1: TIdIPWatch;
procedure Button2Click(Sender: TObject);
procedure ClientSocket1Connect(Sender: TObject; Socket: TCustomWinSocket);
procedure Delay(time: word);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
cryptlicense:Integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function myCoder(s:
string; password: Integer; decode: Boolean):
string;
var
i, c, x: Integer;
begin
if decode
then x := -1
else x := 1;
RandSeed := password;
Result := '
';
for i := 1
to length(s)
do
begin
c := ord(s[i]);
if c
in [32..122]
then
begin
c := c+(x*Random(90));
if (c<32)
or (c>122)
then c := c-(x*90);
end;
Result := Result + chr(c);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
license:
String;
compare:
String;
request :
string;
begin
compare:=Kennung.Text+Pass.Text;
license := myCoder(compare, StrToInt(servpass.Text), False);
ClientSocket1.Host:=ServerIp.Text;
ClientSocket1.Active:=True;
request:=license;
delay(500);
ClientSocket1.Socket.SendText(request+'
:'+IdIPWatch1.LocalIP);
Button1.Enabled :=false;
Button2.Enabled :=true;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
delay(500);
ClientSocket1.Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ServMessage.Lines.add('
Projekt Version 0.1 BETA');
ServMessage.Lines.add('
------------------------');
ServMessage.Lines.add('
Login Consol Ready ');
ServMessage.Lines.add('
Locale IP:'+IdIPWatch1.LocalIP);
ServMessage.Lines.add('
------------------------');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ClientSocket1.Socket.SendText(Kennung.Text+'
abgemeldet');
ClientSocket1.Close;
ServMessage.Lines.add('
Abmeldung vom Server');
Button1.enabled:=true;
Button2.enabled:=false;
end;
procedure TForm1.ClientSocket1Connect(Sender: TObject;
Socket: TCustomWinSocket);
begin
ServMessage.Lines.add('
Client meldet: Verbunden (001) :: '+TimeToStr(now));
end;
procedure TForm1.Delay(time: word);
var Start : Integer;
begin
Start:=GetTickCount;
while (GetTickCount)-(Start) <= time
do
Application.ProcessMessages;
end;
end.