This is the code to a small utility that I wrote. This app recovers passwords from Microsoft Access databases. Don't ever trust the simplistic security on Access.
I like to think that anyone could read this code and understand how it works. I have removed all of the comments but the code remains readable and easy to maintain. Try that with C.
unit MainForm; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) OpenDialog1: TOpenDialog; EditFileName: TEdit; ButtonSelectFile: TButton; ButtonGetPassword: TButton; Label1: TLabel; LabelPassword: TLabel; procedure ButtonSelectFileClick(Sender: TObject); procedure ButtonGetPasswordClick(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.ButtonSelectFileClick(Sender: TObject); begin If openDialog1.Execute then EditFileName.Text:=OpenDialog1.FileName; end; procedure TForm1.ButtonGetPasswordClick(Sender: TObject); Const XorArray : Array[1..13] of Integer = ($86, $FB, $EC, $37, $5D, $44, $9C, $FA, $C6, $5E, $28, $E6, $13); Var FileHandle, Counter : Integer; PasswordBuffer : Array[1..14] of Byte; PasswordString : Array[1..14] of char; begin FileHandle := FileOpen(EditFileName.Text, fmOpenRead or fmShareDenyNone); If FileHandle < 0 then Begin MessageDlg('Could not open file!!',mtError,[mbOK],0); Exit; End; If FileSeek(FileHandle, $42, 0) < 0 then Begin MessageDlg('Could not seek into file!! File Truncated?',mtError,[mbOK],0); Exit; End; If FileRead(FileHandle, PasswordBuffer, SizeOf(PasswordBuffer)) < 0 then Begin MessageDlg('Could not read file!!',mtError,[mbOK],0); Exit; End; for Counter := 1 to 14 do Begin PasswordBuffer[Counter] := (PasswordBuffer[Counter] xor XorArray[Counter]); PasswordString[Counter] := Char(PasswordBuffer[Counter]); End; LabelPassword.Caption:=PasswordString; end; end.