function Getpasswordfromaccess (afilename:string): string;
Var
Myms:tmemorystream;
B:array of Byte;
A:ARRAY[0..33] of Byte;
Mysfilename, myspwd:string;
I:integer;
Ver:byte;
Mybyte1, Mybyte2:byte;
Const
AR_KEY:ARRAY[0..31] of integer= ($39,$59, $EC, $37, $E 2, $e 6,$9c, $FA, $79, $FC, $28, $E 6, $AC, $14,$8a,$60, $EB, $36,$7b,$36, $4A,
$D 0, $DF, $B 1, $C 8,$56,$13,$43,$70,$0d, $b 1,$33);
Flagbyte1 = $8b;
Flagbyte2 = $C 3;
Begin
If not fileexists (afilename) then Exit;
Mysfilename: = Afilename;
Myms: = tmemorystream.create;
Try
Myms. LoadFromFile (Mysfilename);
Myms. Position: = 0;
Myms. Seek ($14, 0);
Myms. Read (ver, SizeOf (Byte)); Here we get Access version, 1 and 0 is97
SetLength (b, 2);
Myms. Seek ($42, 0);
Myms. Read (a[0], sizeof (a));
Mybyte1: = a[32] XOR flagbyte1;
Mybyte2: = a[33] XOR Flagbyte2;
For I: = 0 To
Begin
B[0]: = Ar_key[i*2] xor a[i*2];
B[1]: = Ar_key[i*2+1] xor a[i*2+1];
if (i mod 2 = 0) and (ver = 1) Then
Begin
B[0]: = B[0] XOR mybyte1;
B[1]: = b[1] XOR Mybyte2;
End
Myspwd: = myspwd + Char (b[0]+b[1]);
End
Result: = myspwd;
Finally
SetLength (b, 0);
Myms. Free;
End
End
Delphi Get MDB Password