2. Overview
Objective
Learn how to encrypt and decrypt data.
Requirements
Version of ProdigyView
Estimated Time
8 Minutes
www.prodigyview.com
3. Follow Along With Code Example
1. Download a copy of the example code at
www.prodigyview.com/source.
2. Install the system in an environment you feel comfortable testing in.
3. Proceed to examples/security/Encryption.php
4. Encrpytion A Nightmare
The first time coming across encryption and php mcrypt
can be something like this:
5. Encryption Made Easy
Thankfully encryption is not like that in ProdigyView. Start
this example by calling the PVSecurity::init and lets
create a string to encrypt.
1. Initialize the security class
2. String to encode
6. Encrypting Data
Encrypting data is easily accomplished by passing data
into the PVSecurity::encrypt method.
Encrypt the string
7. Encrypting String
Trying to read an encrypted string will give you this result.
To read that message, we have to decrypt the message in
PVSecurity::decrypt
8. Encrypting with Key
By default, the key used is defined in the
PVSecurity::init. A custom key can be used when
encrypting a string and only that key can be used to
decrypt it.
Custom key for encrypting
9. Decrypting with Custom Key
Our last string we encrypted was with a set key.
Decrypting without the correct key will give us this.
Decrypting with the key used for encryption will return
this.
10. Review
1. Encrypt a file with PVSecurity::encrypt.
2. Decrypt a file with PVSecurity::decrypt.
3. Custom key have can be added in the options of
encrypt and decrypt.
4. PVSecurity::init contains the default configuration for
encrypting and decrypting data.
11. API Reference
For a better understanding of Validation in ProdigyView, visit
the api by clicking on the link below.
PVSecurity
More Tutorials
For more tutorials, please visit:
http://www.prodigyview.com/tutorials
www.prodigyview.com