Switch to: V12V11V10V9V8V7V6V5

VDatabase Class: Encryption Methods

The VDataBase class has encryption methods that allows you to encrypt data of database as well as the structure of a database.

Encryption of the structure allows you to deny opening of your database files using any other programs based on the Valentina database.

Usually you will use one of the encryption methods of the database, though it is posible to merge both of them.

VDatabase.Encrypt()

Encrypt(
    inKey as String
    inForData as EVDataKind = kRecordsOnly )

Parameters:

  • inKey - The key of encryption.
  • inForData - Specifies what data are encrypted.

Description:

Allows you to encrypt the database.

Using the inForData parameter you can specify what data must be encrypted. inForData may accept following values:

  • kRecordsOnly - records of the database are encrypted.
  • kStructureOnly - the structure of the database (.vdb file) is encrypted.
  • kRecordsAndStructure - records and the structure are encrypted with the same password.

When the function completes the work, you get an encrypted database on the disc. To future work with this database you need to assign the encryption key using the UseEncryptionKey() function.

Working time of the function is directly as the size of the database.

ATTENTION: If the key is lost there is no posibility to decrypt data.

Note:

  • The database must be open.
  • You can encrypt either an empty database or the database that already has records.
  • All new tables/fields added in the database will be encrypted the same way.
  • All new records added in the database will be encrypted.

Example:

db.Open()
db.Encrypt ( "key12345" )

Example:

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

VDatabase.Decrypt()

Declaration:

Decrypt(
	inKey as String
	inForData as EVDataKind = kRecordsOnly )

Parameters:

  • inKey - The encription key.
  • inForData - Specifies what data are encrypted.

Description:

Allows to decrypt the database.

If the database already has records then they are encrypted on the disc. When the function completes the work, you get the decrypted database which does not need the encryption key for access.

Working time of this function is directly as the size of the database.

Example:

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

Example:

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

VDatabase.ChangeEncryptionKey()

Declaration:

ChangeEncryptionKey(
    inOldKey as String
    inNewKey as String
    inForData as EVDataKind = kRecordsOnly )

Parameters:

  • inOldKey - Old encryption key.
  • inNewKey - New encryption key.
  • inForData - Specifies what data are encrypted.

Description:

Allows you to change the encryption key for the database.

Working time of this function is directly as the size of the database.

Example:

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

Example:

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

VDatabase.RequiresEncryptionKey()

Declaration:

RequiresEncryptionKey() as boolean

Description:

Returns True if the database is encrypted, otherwise returns False.

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 = db.RequiresEncryptionKey()

VDatabase.UseEncryptionKey()

Declaration:

UseEncryptionKey(
	inKey as String
	inForData as EVDataKind = kRecordsOnly )

Parameters:

  • inKey - The encryption key.
  • inForData - Specifies what data are encrypted.

Description:

Informs the database what key must be used for data encryption.

Returns an error “wrong key”, if you specify a wrong key of encryption.

Example:

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

Example:

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