SRL Archive - Other Scripts

Adv. Geocache Riddle Decoder


Smartzkid

2007-05-08 20:02:39

I made this as an exercise in forms, because I need to practice a bit on them for my secret scripting project

For reasons unknown to me, the dragging (double click and drag) on this still won't work right, but I'll release it anyway (uses farno's riddle decoding engine)

program X;
const
Speedy = False; //Set to true if you want conversions to be instant
var
frmDesign: TForm;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Button1: TButton;
ProgressBar1: TProgressBar;
Button2: TButton;
enc, rev: boolean;
x, s, m, n: integer;
tstr, show1, show2: string;
str2: char;

procedure Move(Sender: TObject);
var
x1, y1, x2, y2: integer;
begin
getmousepos(x1, y1);
x1 := frmDesign.Left - x1;
y1 := frmDesign.Top - y1;
repeat
wait(5);
if(IsMouseButtonDown(true))then
begin
getmousepos(x2, y2);
frmDesign.Left := x2 + x1;
frmDesign.Top := y2 + y1;
m := x2 + x1;
n := y2 + y1;
end;
until(not(IsMouseButtonDown(true)))
end;

procedure Close(Sender: TObject);
begin
frmDesign.Modalresult := mrOk;
end;

procedure Encrypt(Sender: TObject);
begin
if (Edit1.Text = '') then
Exit;

Button1.Visible := False;
Button2.Visible := False;
ProgressBar1.Visible := True;
ProgressBar1.Min := 0;
ProgressBar1.Max := Length(Edit1.Text) * 2;
ProgressBar1.Position := 0;

x := 1;
enc := true;
tstr := Edit1.Text;
s := 1 + random(4);
if (Length(Edit1.Text) mod 2 = 0) then
s := s * 3;
if (Speedy) then
s := 0;
end;

procedure InitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := m;
frmDesign.Top := n;
frmDesign.BorderIcons := [];
frmDesign.BorderStyle := bsNone;
frmDesign.Caption := 'frmDesign';
frmDesign.ClientHeight := 90;
frmDesign.ClientWidth := 195;
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
frmDesign.Ondblclick := @Move;
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign;
Label1.Left := 1;
Label1.Top := 5;
Label1.Width := 64;
Label1.Height := 13;
Label1.Caption := 'Unencrypted:';
Label2 := TLabel.Create(frmDesign);
Label2.Parent := frmDesign;
Label2.Left := 1;
Label2.Top := 26;
Label2.Width := 51;
Label2.Height := 13;
Label2.Caption := 'Encrypted:';
Label3 := TLabel.Create(frmDesign);
Label3.Parent := frmDesign;
Label3.Left := 1;
Label3.Top := 47;
Label3.Width := 56;
Label3.Height := 13;
Label3.Caption := 'Reversified:';
Edit1 := TEdit.Create(frmDesign);
Edit1.Parent := frmDesign;
Edit1.Left := 72;
Edit1.Top := 1;
Edit1.Width := 121;
Edit1.Height := 21;
Edit1.TabOrder := 8;
Edit2 := TEdit.Create(frmDesign);
Edit2.Parent := frmDesign;
Edit2.Left := 72;
Edit2.Top := 22;
Edit2.Width := 121;
Edit2.Height := 21;
Edit2.TabOrder := 9;
Edit3 := TEdit.Create(frmDesign);
Edit3.Parent := frmDesign;
Edit3.Left := 72;
Edit3.Top := 44;
Edit3.Width := 121;
Edit3.Height := 21;
Edit3.TabOrder := 10;
Button1 := TButton.Create(frmDesign);
Button1.Parent := frmDesign;
Button1.Left := 1;
Button1.Top := 68;
Button1.Width := 48;
Button1.Height := 20;
Button1.Caption := 'Encrypt';
Button1.TabOrder := 11;
Button1.Onclick := @Encrypt;
ProgressBar1 := TProgressBar.Create(frmDesign);
ProgressBar1.Parent := frmDesign;
ProgressBar1.Left := 3;
ProgressBar1.Top := 70;
ProgressBar1.Width := 190;
ProgressBar1.Height := 16;
ProgressBar1.TabOrder := 12;
ProgressBar1.Visible := False;
Button2 := TButton.Create(frmDesign);
Button2.Parent := frmDesign;
Button2.Left := 144;
Button2.Top := 68;
Button2.Width := 49;
Button2.Height := 20;
Button2.Caption := 'Finish';
Button2.TabOrder := 13;
Button2.Onclick := @Close;
end;

procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;

procedure ShowFormModal;
begin
frmDesign.SHOW;
end;

procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;

begin
SafeInitForm;
SafeShowFormModal;
repeat
wait(10);

if (enc) then
begin
str2 := tstr[x];

if (str2 = '''') then
tstr[x] := '''';
if (str2 = ' ') then
tstr[x] := ' ';
if (str2 = ',') then
tstr[x] := ',';
if (str2 = '.') then
tstr[x] := '.';
if (str2 = '?') then
tstr[x] := '?';
if (str2 = '!') then
tstr[x] := '!';
if (str2 = '*') then
tstr[x] := '*';
if (str2 = '=') then
tstr[x] := '=';
if (str2 = ')') then
tstr[x] := ')';
if (str2 = '(') then
tstr[x] := '(';
if (str2 = 'a') then
tstr[x] := 'n';
if (str2 = 'b') then
tstr[x] := 'o';
if (str2 = 'c') then
tstr[x] := 'p';
if (str2 = 'd') then
tstr[x] := 'q';
if (str2 = 'e') then
tstr[x] := 'r';
if (str2 = 'f') then
tstr[x] := 's';
if (str2 = 'g') then
tstr[x] := 't';
if (str2 = 'h') then
tstr[x] := 'u';
if (str2 = 'i') then
tstr[x] := 'v';
if (str2 = 'j') then
tstr[x] := 'w';
if (str2 = 'k') then
tstr[x] := 'x';
if (str2 = 'l') then
tstr[x] := 'y';
if (str2 = 'm') then
tstr[x] := 'z';
if (str2 = 'n') then
tstr[x] := 'a';
if (str2 = 'o') then
tstr[x] := 'b';
if (str2 = 'p') then
tstr[x] := 'c';
if (str2 = 'q') then
tstr[x] := 'd';
if (str2 = 'r') then
tstr[x] := 'e';
if (str2 = 's') then
tstr[x] := 'f';
if (str2 = 't') then
tstr[x] := 'g';
if (str2 = 'u') then
tstr[x] := 'h';
if (str2 = 'v') then
tstr[x] := 'i';
if (str2 = 'w') then
tstr[x] := 'j';
if (str2 = 'x') then
tstr[x] := 'k';
if (str2 = 'y') then
tstr[x] := 'l';
if (str2 = 'z') then
tstr[x] := 'm';
if (str2 = 'A') then //CAPS
tstr[x] := 'N';
if (str2 = 'B') then
tstr[x] := 'O';
if (str2 = 'C') then
tstr[x] := 'P';
if (str2 = 'D') then
tstr[x] := 'Q';
if (str2 = 'E') then
tstr[x] := 'R';
if (str2 = 'F') then
tstr[x] := 'S';
if (str2 = 'G') then
tstr[x] := 'T';
if (str2 = 'H') then
tstr[x] := 'U';
if (str2 = 'I') then
tstr[x] := 'V';
if (str2 = 'J') then
tstr[x] := 'W';
if (str2 = 'K') then
tstr[x] := 'X';
if (str2 = 'L') then
tstr[x] := 'Y';
if (str2 = 'M') then
tstr[x] := 'Z';
if (str2 = 'N') then
tstr[x] := 'A';
if (str2 = 'O') then
tstr[x] := 'B';
if (str2 = 'P') then
tstr[x] := 'C';
if (str2 = 'Q') then
tstr[x] := 'D';
if (str2 = 'R') then
tstr[x] := 'E';
if (str2 = 'S') then
tstr[x] := 'F';
if (str2 = 'T') then
tstr[x] := 'G';
if (str2 = 'U') then
tstr[x] := 'H';
if (str2 = 'V') then
tstr[x] := 'I';
if (str2 = 'W') then
tstr[x] := 'J';
if (str2 = 'X') then
tstr[x] := 'K';
if (str2 = 'Y') then
tstr[x] := 'L';
if (str2 = 'Z') then
tstr[x] := 'M';
if (str2 = '1') then
tstr[x] := '1';
if (str2 = '2') then
tstr[x] := '2';
if (str2 = '3') then
tstr[x] := '3';
if (str2 = '4') then
tstr[x] := '4';
if (str2 = '5') then
tstr[x] := '5';
if (str2 = '6') then
tstr[x] := '6';
if (str2 = '7') then
tstr[x] := '7';
if (str2 = '8') then
tstr[x] := '8';
if (str2 = '9') then
tstr[x] := '9';
ProgressBar1.Position := x / 2;
wait(10 * s + random(30 * s));
show1 := show1 + tstr[x];
show2 := show2 + tstr[x];
Edit2.Text := show1;
Edit3.Text := show2;

x := x + 1;

if (x > Length(Edit1.Text)) then
begin
enc := false;
rev := true;
tstr := Edit2.Text;
x := Length(Edit1.Text);
end;
end;

if (rev) then
begin
str2 := Edit2.Text[x];
tstr[Length(Edit2.Text) - x + 1] := str2;
Edit3.Text := tstr;
ProgressBar1.Position := ProgressBar1.Max - x;
wait(35 * s + random(20 * s));
x := x - 1;
if (x < 1) then
begin
Button1.Visible := True;
Button2.Visible := True;
ProgressBar1.Visible := False;
rev := false;
end;
end;
until (frmDesign.Modalresult = mrOk)
end.

Dunceiam

2007-05-08 22:37:41

bbb…snapl arj ynlbhg. Tbbq wbo Fznegm, V jnf nobhg gb nfx jungf jebat jvgu vg. Urur. Yrg'f ubcr guvf jbexf!

-Qhaprvnz

(Jnvg…ubj qb lbh qrpbqr vg?)
(Wait…how do you decode it?)

PwNZoRNooB

2007-05-09 10:02:57

Lol, that really would be nice practice but I don't know how to do forms (yet ;))