Switch to: V9V8V7V6V5

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.

VTable.Encrypt()

Encrypt(
    inKey as String )

Parameters:

  • inKey - The key of encryption.

Description:

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.

Example:

tbl.Encrypt ( "key12345" )

VTable.Decrypt()

Declaration:

Decrypt(
	inKey as String )

Parameters:

  • inKey - The encription key.

Description:

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.

Example:

tbl.Decrypt ( "key12345" )

Example:

db.Open()
db.Decrypt ( "key12345", kStructureOnly )

VTable.ChangeEncryptionKey()

Declaration:

ChangeEncryptionKey(
    inOldKey as String,
    inNewKey as String )

Parameters:

  • inOldKey - Old encryption key.
  • inNewKey - New encryption key.

Description:

Allows you to change the encryption key for the Table. Working time of this function is directly as the size of the Table.

Example:

res = tbl.ChangeEncryptionKey( "key12345", "key54321"  )

Example:

res = db.ChangeEncryptionKey( "key12345", "key54321", kStructureOnly )

VTable.RequiresEncryptionKey()

Declaration:

RequiresEncryptionKey() as boolean

Description:

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.

Example:

res = tbl.RequiresEncryptionKey()

VTable.UseEncryptionKey()

Declaration:

UseEncryptionKey(
	inKey as String )

Parameters:

  • inKey - The encryption key.

Description:

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.

Example:

db.Open()
db.Table("Person").UseEncryptionKey( "key12345" )