// Specify the default encryption key to be used when // an encrypted table is accessed encrypt table1 key "key_1,key_2,key_3" encrypt table2 key "key_2,key_3,key_4" set encryption to "key_1,key_2,key_3" use table1 use table2<key_2,key_3,key_4> set encryption to use table1 encryption "key_1,key_2,key_3" use table2<key_2,key_3,key_4>
decrypt accounts key "key1,key2,key3" decrypt salaries key "<key_1,key_2,key_3>" // decrypt all .dbf files in the directory decrypt *.dbf key "key1,key2,key3"
encrypt accounts key "key1,key2,key3" encrypt salaries key "<key_1,key_2,key_3>" // encrypt all .dbf files in the directory encrypt *.dbf key "key1,key2,key3"
md5key = md5("Oeh987we") ? md5key 20aed6c51c904428ee6a60d3f460f0cb
https://www.lianja.com/doc/index.php/MD5()
// Write encoded password to a file m_pass=space(10) @10,10 get m_pass read strtofile(base64_encode(m_pass),"password.txt")
https://www.lianja.com/doc/index.php/BASE64_ENCODE()
// Check password against file m_pass=space(10) @10,10 get m_pass read if m_pass <> base64_decode(filetostr("password.txt")) // invalid password return endif
https://www.lianja.com/doc/index.php/BASE64_DECODE()
md5key = md5file("*.dbf") ? md5key a867a1593181165651ed1e4330f451ba
https://www.lianja.com/doc/index.php/MD5FILE()
? sha1("The quick brown fox jumps over the lazy dog") 2FD4E1C67A2D28FCED849EE1BB76E7391B93EB12
https://www.lianja.com/doc/index.php/SHA1()
open database southwind ? sha1file("*.dbf") DA39A3EE5E6B4B0D3255BFEF95601890AFD80709
https://www.lianja.com/doc/index.php/SHA1FILE()
? crc32("Lianja")
https://www.lianja.com/doc/index.php/CRC32()
cEncrypted = des3_encrypt("LIANJA","abcdEFGH","ijklm123","45673$%^") cDecrypted = des3_decrypt(cEncrypted,"abcdEFGH","ijklm123","45673$%^")
https://www.lianja.com/doc/index.php/DES3_DECRYPT()
cEncrypted = des3_encrypt("LIANJA","abcdEFGH","ijklm123","45673$%^") cDecrypted = des3_decrypt(cEncrypted,"abcdEFGH","ijklm123","45673$%^")
https://www.lianja.com/doc/index.php/DES3_ENCRYPT()
// Encrypt individual tables encrypt customers key "key_1,key_2,key_3" encrypt employees key "<key_1,key_2,key_3>" // Encrypt all .dbf files in the directory encrypt *.dbf key "key_1,key_2,key_3"
// Encrypt individual tables encrypt customers key "key_1,key_2,key_3" encrypt shippers key "key_2,key_3,key_4" // Specify a default encryption key set encryption to "key_1,key_2,key_3" // Open customers table using the default encryption key use customers // Specify shippers table's encryption key use shippers<key_2,key_3,key_4> // Disable the default encryption key set encryption to // Specify the individual encryption keys use customers encryption "key_1,key_2,key_3" use shippers<key_2,key_3,key_4>
// Decrypt individual tables decrypt customers key "key_1,key_2,key_3" decrypt employees key "<key_1,key_2,key_3>" // Decrypt all .dbf files in the directory decrypt *.dbf key "key_1,key_2,key_3"
Affected Commands
All of the following commands are affected when a table is encrypted:
Append from
append from – append records to the active table from another table
// The key must be specified for an encrypted source table use mycustomers append from customers encryption "key_1,key_2,key_3"; for country = "UK"
Copy file
copy file – copy a file
// The key file must also be copied for an encrypted source table // as the target table will be encrypted encrypt customers key "key_1,key_2,key_3" copy file customers.dbf to newcustomers.dbf copy file customers.dkf to newcustomers.dkf use newcustomers encryption "key_1,key_2,key_3"
Copy structure
copy structure – copy a table’s structure to a new table
// The key file is automatically copied for an encrypted source table // and the target table encrypted encrypt customers key "key_1,key_2,key_3" use customers encryption "key_1,key_2,key_3" copy structure to blankcust use blankcust encryption "key_1,key_2,key_3"
Copy
copy – copy a table
// By default, the key file is automatically copied for an encrypted // source table and the target table encrypted with the same key encrypt customers key "key_1,key_2,key_3" use customers encryption "key_1,key_2,key_3" copy to newcustomers use newcustomers encryption "key_1,key_2,key_3" // You can also create a copy with a different key encrypt customers key "key_1,key_2,key_3" use customers encryption "key_1,key_2,key_3" copy to newcustomers encrypt "newkey_1,newkey_2,newkey_3" use newcustomers encryption "newkey_1,newkey_2,newkey_3" // Or create a decrypted copy encrypt customers key "key_1,key_2,key_3"; use customers encryption "key_1,key_2,key_3" copy to newcustomers decrypt use newcustomers // You can also create an encrypted copy of a non-encrypted source table use orders copy to encorders encrypt "newkey_1,newkey_2,newkey_3" use encorders encryption "newkey_1,newkey_2,newkey_3"
Use
use – open a table
// The three part key must be specified to open an // encrypted table. All of the following are valid. // 1. Specifying a default encryption key before opening the table set encryption to "key_1,key_2,key_3" use customers // 2. Appending the key to the filename use customers<key_1,key_2,key_3> // 3. Using the ENCRYPTION clause, optionally specifying angled brackets use customers encryption "key_1,key_2,key_3" use customers encryption "<key_1,key_2,key_3>"
Insert
SQL insert – add a row to a table
// The three part key can be specified using a // default encryption key before opening the table open database southwind set encryption to "key_1,key_2,key_3" insert into customers; (customerid, companyname); values ("LIANJ","Lianja Inc") // Or by appending the key to the filename open database southwind insert into customers<key_1,key_2,key_3>; (customerid, companyname); values ("LIANJ","Lianja Inc")
Select
SQL select – return data from a table or tables
// The three part key can be specified using a // default encryption key before opening the table open database southwind set encryption to "key_1,key_2,key_3" select * from customers // Or by appending the key to the filename open database southwind select * from customers<key_1,key_2,key_3>
Update
SQL update – update data in a table
// The three part key can be specified using a // default encryption key before opening the table open database southwind set encryption to "key_1,key_2,key_3" update customers; set companyname="Lianja Inc."; where customerid="LIANJ" // Or by appending the key to the filename open database southwind update customers<key_1,key_2,key_3>; set companyname="Lianja Inc."; where customerid="LIANJ"
https://www.lianja.com/doc/index.php/Encryption