Table of Contents
VField Class: Encryption Methods
The VField class has a set of functions for encryption analog to functions of the VDatabase and VTable classes.
You may wish to use these functions if you want to encrypt only one or several Fields 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 Field in case if its database or table (i.e. an object on higher level) is encrypted before.
VField.Encrypt()
Encrypt( inKey as String )
Parameters:
- inKey - The key of encryption.
Description:
Allows you to encrypt the Field.
When the function completes work, you get an encrypted Field on the disc. To future work with this Field you need to assign the encryption key using the UseEncryptionKey() function.
Working time of the function is directly as the size of the Field.
ATTENTION: If the key is lost there is no possibility to decrypt data.
Example:
tbl.Encrypt ( "key12345" )
VField.Decrypt()
Declaration:
Decrypt( inKey as String )
Parameters:
- inKey - The encription key.
Description:
Allows to decrypt the Field.
If the Field already has records then they are decrypted on the disc. When the function completes the work, you get the decrypted Field which does not need the encryption key for access.
Working time of this function is directly as the size of the Field.
Example:
tbl.Decrypt ( "key12345" )
Example:
db.Open() db.Decrypt ( "key12345", kStructureOnly )
VField.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 Field. Working time of this function is directly as the size of the Field.
Example:
res = tbl.ChangeEncryptionKey( "key12345", "key54321" )
Example:
res = db.ChangeEncryptionKey( "key12345", "key54321", kStructureOnly )
VField.RequiresEncryptionKey()
Declaration:
RequiresEncryptionKey() as boolean
Description:
Returns True if the field is encrypted, otherwise returns False.
ATTENTION: if you have encrypt the entire database or table of this field (i.e. an object on higher level) than this method will return False for this field, because this field do not have own key.
This function can be used with programs such as Valentina Studio to check wether it is necessary to show an user the dialog for password entry.
Example:
res = tbl.RequiresEncryptionKey()
VField.UseEncryptionKey()
Declaration:
UseEncryptionKey( inKey as String )
Parameters:
- inKey - The encryption key.
Description:
Informs the field what key must be used for data encryption.
Returns an error “wrong key”, if you specify a wrong key of encryption.
This function must be called just if VField.RequiresEncryptionKey() returns True for this Field.
ATTENTION: while the VDatabase.UseEncryptionKey() method must be called before opening of the database, the VField.UseEncryptionKey() methods must be called after opening the database and before the first attempt to work with data of the Field.
Example:
db.Open() fld.UseEncryptionKey( "key12345" )