Show/Hide Toolbars

Navigation: Using ASPRunnerPro > Security

PHPrunner32x32     ASPRunnerPro manual


Encryption

Scroll Prev Next More

 

The Encryption feature allows you to encrypt important data in the database, such as credit card numbers or Social Security numbers. You need to select the encryption method, enter the encryption key, and choose the fields to be encrypted.

 

yellowbulbNote: Encryption feature is available only in the Enterprise Edition of ASPRunnerPro. See Editions Comparison.

 

Press the Encryption button on the Security screen to open the Encryption popup.

encryption_n

 

You can select a Database-based or Code-based encryption method.

 

yellowbulbNote: the Database-based encryption method is available only for MySQL, Oracle, PostgreSQL, and MS SQL Server databases.

 

The Database-based method is preferable since it has more features than the Code-based method. With the Database-based encryption, for example, the encrypted fields can be sorted and grouped, the search offers suggestions and includes all operators (CONTAINS, EQUALS, MORE THAN, etc.).

 

Database-based encryption requirements

PostgreSQL:

install the pgcrypto module.

 

Oracle:

give users full rights to the SYS.DBMS_CRYPTO package;

the Oracle version must be 10 or higher.

 

MySQL:

enable SSL support.

 

Encryption key

We recommend using the encryption key that is at least 10 characters long.

You can also use the Generate button to generate a random key.

 

ASPRunnerPro can encrypt only the text fields. Since the encrypted value usually is at least 2-3 times longer than source value, you should choose the maximum length fields such as TEXT in MySQL or MEMO in MS Access.

 

yellowbulbNote: ASPRunnerPro does not encrypt the existing data. Encryption is applied to the record during the Add/Edit operations.

 

yellowbulbNote: once the encrypted data is stored in the database, you should not change the encryption type and key, or deactivate the encryption, as the data will remain encrypted.

 

Here is an example of encrypted data in the application:

encryption_example_n

 

Functions used for database-based encryption

 

Oracle:

Encryption: DBMS_CRYPTO.ENCRYPT()

Decryption: DBMS_CRYPTO.DECRYPT()

 

MS SQL Server:

Encryption: EncryptByPassPhrase(), EncryptByKey()

Decryption: DecryptByPassPhrase(), DecryptByKey()

 

MySQL:

Encryption: DES_ENCRYPT(), AES_ENCRYPT()  

Decryption: DES_DECRYPT(), AES_DECRYPT()

 

PostgreSQL:

Encryption: pgp_sym_encrypt()

Decryption: pgp_sym_decrypt()

 

Encrypt existing values in the database

yellowbulbNote: before starting this procedure, make a backup of the database!

 

You may encrypt the existing values only once. We do not recommend double encryption as it causes problems with decryption.

 

yellowbulbNote: it is not possible to determine after the encryption whether the data had been encrypted or not.

 

To encrypt the existing values in the database, add the following code to the List page: Before process event of your table:

 

asp_include "ciphcoding.asp", false

 

Then run the List page that contains the encrypted fields with the ciphcoding=1 parameter, e.g.:

 

mytable_list.asp?ciphcoding=1

 

Once the data has been encrypted, it is necessary to delete the file ciphcoding.asp in the output directory, remove the code from the List page: Before process event and re-upload the application.

 

We recommend performing this procedure on the development machine or a server without public access.

 

Decrypt custom query results

MySQL, AES encryption

 

The key variable should contain the encryption key specified in ASPRunnerPro on the Encryption screen.

 

//define encryption key
 
key="09a308862fbe462095dd6eba33ab9dd21b8fd35b0d884b48819a34ce8636983b"
 
sql = "SELECT cast(AES_DECRYPT(unhex(customer_name), '" & key & "') as char) AS custname FROM customers_table WHERE id = 'CUST123'"  
doAssignment rs, CustomQuery(sql)
doAssignment data, db_fetch_array(rs)
 
response.write data("custname")