Encrypt/Decrypt
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 602   6
URL.หัวข้อ / URL
Encrypt/Decrypt

Encrypt/Decrypt คืออะไรครับ ใช้ทำอะไร ไม่เคยใช้เลย

6 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R05414
คงได้แค่ทดลองเพื่อพิสูจน์ตามที่เว็บต่างประเทศเขาชี้แจงไว้ครับ
แต่ยังไม่พบความแตกต่างเหมือนกัน
http://www.developer.com/tech/article.php/724731
2 @R05429
ผมได้ลองเขียน code การทำ encrypt / decrypt (ใน code เขียนว่า encryptback) สำหรับ Textpassword เพื่อป้องกันการ hack ข้อมูล (ในระดับหนึ่งเท่านั้น)
ทดลองโดยเปิด form login แล้วใส่ USER กับ PASSWORD ดูนะครับ
(แต่ข้อมูลใน table มันจะเก็บค่าที่ encrypt แล้ว)
USER = ADMIN
PASSWORD = ADMIN

ลองเปิด DecryptPWD เพื่อดูคำสั่งการ Decrypt Text Password ดูนะครับ
3 @R05431
สรุปว่า มันเป็นเรื่องการแปลงตัวอักษรเพื่อป้องกันไม่ให้สามารถอ่านได้
ใช่หรือเปล่าครับ งง (ภาษาอังกฤษ ไม่ค่อยได้ครับ)
4 @R05433
Encrypting a Database
If you want to protect your secured database from unauthorized access by someone who is using a disk editor or other utility program, you can encrypt it. Encryption makes a database indecipherable, which protects it from unauthorized viewing or use, particularly during electronic transmission or when it's stored on floppy disk, tape, or compact disc. Encrypting an unsecured database will have no effect because anybody can open the database with Access or VBA and gain full access to all objects in the database.

Important Before you can encrypt or decrypt an Access database, you must be either the owner of the database or, if the database has been secured, a member of the Admins group of the workgroup information file that contains the accounts used to secure the database. You must also be able to open the database in exclusive mode, which, if the database is secured by using User-Level security, requires you to have the Open/Run and Open Exclusive permissions.

The User-Level Security Wizard automatically encrypts your database. You can encrypt or decrypt a database by starting Access without opening a database, and then using the Encrypt/Decrypt Database command (Tools menu, Security submenu). When you encrypt a database by using the same file name as that of the original database, Access deletes the original unencrypted file if the encryption process is successful. If an error occurs, Access doesn't delete the original file.

Note Encrypting a database slows its performance by up to 15 percent. Also, an encrypted database cannot be compressed by programs such as DriveSpace or PKZIP. If you try to compress an encrypted database, its size doesn't change.

You can also use the CompactDatabase method of the Microsoft Jet and Replication Objects (JRO) 2.1 JetEngine object to encrypt or decrypt a database. To use the JRO JetEngine object, you must set a reference to the Microsoft Jet and Replication Objects 2.1 object library. When you use the CompactDatabase method, you can't save the compacted (and optionally encrypted) database to the same name as the original database. The CompactDatabase method takes two arguments to specify the source database and the destination database: SourceConnection and DestConnection. Both the SourceConnection and DestConnection arguments take the form of connection strings. Within the connection strings, you specify various connection properties to determine how the source database is opened and how the destination database is compacted. At a minimum, you must use the Data Source property in each connection string to specify the path and name of the database. Additionally, to encrypt the database, you must include the Jet OLEDB:Encrypt Database property in the connection string for the DestConnection argument. The following procedure uses these connection properties to encrypt the database specified by the strSourceDB argument to the path and name specified by the strDestDB argument:

Function EncryptDb(strSourceDB As String, _
strDestDB As String) As String
Dim jetEngine As JRO.JetEngine
Dim strSourceConnect As String
Dim strDestConnect As String

' Build connection strings for SourceConnection and
' DestConnection arguments.
strSourceConnect = "Data Source=" & strSourceDB
strDestConnect = "Data Source=" & strDestDB & ";" & _
"Jet OLEDB:Encrypt Database=True"

Set jetEngine = New JRO.JetEngine

' Compact and encrypt the database specified by strSourceDB
' to the name and path specified by strDestDB.
jetEngine.CompactDatabase strSourceConnect, strDestConnect

Set jetEngine = Nothing
End Function

The EncryptDb procedure is available in the modSecurity module in AccessSecurity.mdb in the ODETools\V9\Samples\ODETools\V9\Samples\OPG\Samples\CH18 subfolder on the Office 2000 Developer CD-ROM.

If the database you are encrypting or compacting is secured with User-Level security or a database password, to open the source database you must specify additional connection properties in the connection string for the SourceConnection argument. When specifying additional properties in the connection string, separate each property with a semicolon (;). The following table lists these properties.

Connection property Description
User ID The name of the user account used to open the database if the source database is secured with User-Level security.
Password The password for the user account specified by the User ID property.
Jet OLEDB:System Database The path and name of the system database (workgroup information file) that contains the user and group accounts for User-Level security.
Jet OLEDB:Database Password The password required to open the database if the database is password-protected.


The connection string for both the SourceConnection and DestConnection arguments also accepts the Provider property, but the OLE DB provider for Microsoft Jet 4.0 (Microsoft.Jet.OLEDB.4.0) is assumed by default, so you don't have to specify it within the string. The connection strings can also include other properties to determine how the database is compacted. For more information about using the JRO CompactDatabase method, search Microsoft ADO Help (C:\Program Files\Common Files\System\Ado\Ado210.chm) or the Microsoft Access Visual Basic Reference Help index for "CompactDatabase method."
5 @R05439
Q:
สรุปว่า มันเป็นเรื่องการแปลงตัวอักษรเพื่อป้องกันไม่ให้สามารถอ่านได้
ใช่หรือเปล่าครับ งง (ภาษาอังกฤษ ไม่ค่อยได้ครับ)

A:
ไม่ใช่การแปลงตัวอักษรเพื่อป้องกันไม่ให้อ่านได้ ด้วย ms-access แต่จะเป็นการป้องกันการ อ่านจากโปรแกรมอื่นๆ
เพราะเมนูคำสั่ง Encrypt/Decrypt Database ใน ms-access
จะเป็นการ เข้ารหัสของ database ไว้ทั้งหมด
ถ้าจะพิจารณาข้อมูลใน table โดยเปิดจาก โปรแกรม access แล้วจะไม่เห็นผลของการเข้ารหัสจะยังไม่เห็นความแตกต่างใดๆในตาราง
แต่ถ้าต้องการพิสูจน์หาความแตกต่างระหว่าง Database ที่ Encrypted ไว้แล้ว กับ Database ที่ไม่ได้ทำการ Encrypt
ให้ลองทำแบบนี้ดูครับ ให้เปิดไฟล์ที่ผมแนบมาให้ 3 ไฟล์นี้นะครับ ด้วยโปรแกรม WordPad

มีไฟล์ ชื่อ class.mdb อันนี้เป็นไฟล์ปกติ
ไฟล์ที่สองชื่อ EncryptFromClass.mdb ไฟล์นี้เป็นไฟล์ที่เข้ารหัสไว้
ไฟล์ที่สามชื่อ DecryptFromEncrypt.mdb ไฟล์นี้เป็นไฟล์ที่ถอดรหัสมาจากไฟล์ EncrypFromClass.mdb

ในไฟล์ทั้ง 3 นี้ ใน table ผมบันทึกชื่อ ทักษิณ เอาไว้
เวลาเปิดด้วย wordpad แล้วให้ค้นหาคำว่า ทักษิณ
เราจะพบว่า ไฟล์ class.mdb สามารถค้นหาเจอคำว่า ทักษิณ เพราะไม่ได้เข้ารหัสไว้
แต่ไฟล์ EncryptFromClass.mdb จะค้นไม่เจอคำว่า ทักษิณ เพราะเราเข้ารหัสไว้
และไฟล์ DecryptFromEncrypt.mdb ก็จะค้นหาคำว่า ทักษิณ เจอเช่นเดียวกันกับไฟล์ class.mdb เพราะเป็นไฟล์ที่ผม ถอดรหัสมาจากไฟล์ EncryptFromClass.mdb



6 @R05460
กระจ่าง ขอบคุณทุกท่านครับ
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0586s