Author: Sunish Issac
The password of an access database can easily be retrieved using the function below
Answer:
I know there that there are many utilities out there costing $$ for removing the
password of an access database. Here's how to implement it in Delphi.Please note
that this method is not meant for a database with user-level security and work
group information file. The idea is based on the file format of an access db.
The password is stored from location $42 and encrypted using simple xoring. The
following function does decryption.
1 2 function GetPassword(filename: string): string;
3 var4 Stream: TFilestream;
5 buffer: array[0..12] of char;
6 str: string;
7 begin8 try9 stream := TFileStream.Create(filename, fmOpenRead);
10 except11 ShowMessage('Could not open the file.Make sure that the file is not in use.');
12 exit;
13 end;
14 stream.Seek($42, soFromBeginning);
15 stream.read(buffer, 13);
16 stream.Destroy;
17 18 str := chr(Ord(buffer[0]) xor $86);
19 str := str + chr(Ord(buffer[1]) xor $FB);
20 str := str + chr(Ord(buffer[2]) xor $EC);
21 str := str + chr(Ord(buffer[3]) xor $37);
22 str := str + chr(Ord(buffer[4]) xor $5D);
23 str := str + chr(Ord(buffer[5]) xor $44);
24 str := str + chr(Ord(buffer[6]) xor $9C);
25 str := str + chr(Ord(buffer[7]) xor $FA);
26 str := str + chr(Ord(buffer[8]) xor $C6);
27 str := str + chr(Ord(buffer[9]) xor $5E);
28 str := str + chr(Ord(buffer[10]) xor $28);
29 str := str + chr(Ord(buffer[11]) xor $E6);
30 str := str + chr(Ord(buffer[12]) xor $13);
31 Result := str;
32 end;