Ways to encrypt a background database

Source: Internet
Author: User
Tags header integer table name
The Earth people all know, MDB file is very unsafe, crack MDB file password software endless, that whether if we MDB as a background database, is it tantamount to being trampled on? I think this is not necessarily the case.
I have used a lot of access password crackers, most of them can only handle English passwords, so we can for this feature, the MDB file database password set to Chinese, so you can withstand most of the attack of the cracker.
Some people will say that, since they can write a crack English password Nadia nga  Huan ㄒ Ministry of the 銎 Ping-an-shaped take descurainiae the Na nga u 饩 浠, and the poor Leng Ji-Huai angry  also  Yi-cavity coat weapons 诙  school welding  to raise ?
The first 16 bytes of the MDB store important information such as file types, versions, and so on, and access relies on that information to identify them, and if we change one or more bytes, access will not be able to open them because they can't recognize them, and that's our goal: to encrypt the MDB file. Encryption ideas are as follows:
When the file is opened, the correct header file contents are written to the appropriate location, we can access it from our own program, and when we close the file, we write the contents of the wrong header file to the appropriate location. This has a disadvantage, that is, when the program is running, the background file is accessible, only after the encryption is closed, then when the program is running, others if they know the database password, or can view or export data.
Another approach is to open the background database, immediately establish a physical connection to the end of the program, and then the wrong file header to the appropriate location, so that in the program running, our foreground program is normal access to the background data, and do not know our encryption method is unable to open the background file.

' Enable background access to normal
Function openht (Htmdbpath as String)
Dim FH as Integer
FH = FreeFile
Open Htmdbpath for Binary Access Write as #fh
Put FH, 2, &H1
Close #fh
End Function

' Cause background not to be accessed properly
Function closeht (Htmdbpath as String)
Dim FH as Integer
FH = FreeFile
Open Htmdbpath for Binary Access Write as #fh
Put FH, 2, &h0
Close #fh
End Function

' Below are the functions that establish a physical connection to the background (must be placed in the module)
Public HTCN as Connection
Public htrs as New ADODB. Recordset
Public Htsql as String

' Establish a physical connection
Function OPENSTANDHT ()
Set HTCN = CurrentProject.Connection
' Table 1 to be changed to the corresponding table name
Htsql = "SELECT * FROM Table 1"
Htrs.open Htsql, HTCN, 3, 3, 1
End Function

' Close a physical connection function, such as quitting a program, or shutting down a physical connection when you need to compress a background file
Function CLOSESTANDHT ()
Htrs.close
Set HTCN = Nothing
End Function



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.