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.
Encrypt( inKey as String )
- inKey - The key of encryption.
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.
tbl.Encrypt ( "key12345" )
Decrypt( inKey as String )
- inKey - The encription key.
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.
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 Field. Working time of this function is directly as the size of the Field.
res = tbl.ChangeEncryptionKey( "key12345", "key54321" )
res = db.ChangeEncryptionKey( "key12345", "key54321", kStructureOnly )
RequiresEncryptionKey() as boolean
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.
res = tbl.RequiresEncryptionKey()
UseEncryptionKey( inKey as String )
- inKey - The encryption key.
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.
db.Open() fld.UseEncryptionKey( "key12345" )