Table of Contents
VTable Class: Encryption Methods
The VTable class has a set of functions for encryption analog to the functions of the VDatabase and VField classes.
You may wish to use these functions if you want to encrypt only one or several Tables of a database. It gains speed improvements over having to encrypt an entire database.
Notice, you can not specify the own encryption key for a Table in case if its database (i.e. an object on higher level) was encrypted before.
Encrypt( inKey as String )
- inKey - The key of encryption.
Allows you to encrypt the Table.
When the function completes work, you get an encrypted Table on the disc. For further work with this Table you should assign the encryption key using the UseEncryptionKey() function.
Working time of the function is directly as the size of the Table.
ATTENTION: If the key is lost there is no possibility to decrypt data.
tbl.Encrypt ( "key12345" )
Decrypt( inKey as String )
- inKey - The encription key.
Allows to decrypt the Table.
If the Table already has records then they are decrypted on the disc. When the function completes the work, you get the decrypted Table which does not need the encryption key for the access.
Working time of this function is directly as the size of the Table.
tbl.Decrypt ( "key12345" )
db.Open() db.Decrypt ( "key12345", kStructureOnly )
ChangeEncryptionKey( inOldKey as String, inNewKey as String )
- inOldKey - Old encryption key.
- inNewKey - New encryption key.
Allows you to change the encryption key for the Table. Working time of this function is directly as the size of the Table.
res = tbl.ChangeEncryptionKey( "key12345", "key54321" )
res = db.ChangeEncryptionKey( "key12345", "key54321", kStructureOnly )
RequiresEncryptionKey() as boolean
Returns True if the database is encrypted, otherwise returns False.
ATTENTION: if you encrypted the entire database (i.e. an object on higher level) than this method will return False for this Table, because this table does not have its own key.
This function can be used with programs such as Valentina Studio to check whether it is necessary to show the dialog to the user for password entry.
res = tbl.RequiresEncryptionKey()
UseEncryptionKey( inKey as String )
- inKey - The encryption key.
Informs the database which key should be used for data encryption.
Returns an error “wrong key”, if you specify a wrong key of encryption.
This function should be called just if VTable.RequiresEncryptionKey() returns True for this Table.
ATTENTION: while the VDatabase.UseEncryptionKey() method should be called before opening of the database, the VTable.UseEncryptionKey() methods should be called after opening the database and before the first attempt to work with data of the Table.
db.Open() db.Table("Person").UseEncryptionKey( "key12345" )