Encryption PHP
-
Upload
prodigyview -
Category
Technology
-
view
1.383 -
download
0
description
Transcript of Encryption PHP
![Page 1: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/1.jpg)
Encryption
![Page 2: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/2.jpg)
Overview
Objective
Learn how to encrypt and decrypt data.
Requirements
Version of ProdigyView
Estimated Time
8 Minutes
www.prodigyview.com
![Page 3: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/3.jpg)
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
![Page 4: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/4.jpg)
Encrpytion A NightmareThe first time coming across encryption and php mcrypt can be something like this:
![Page 5: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/5.jpg)
Encryption Made EasyThankfully 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
![Page 6: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/6.jpg)
Encrypting DataEncrypting data is easily accomplished by passing data into the PVSecurity::encrypt method.
Encrypt the string
![Page 7: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/7.jpg)
Encrypting StringTrying to read an encrypted string will give you this result.
To read that message, we have to decrypt the message in PVSecurity::decrypt
![Page 8: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/8.jpg)
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
![Page 9: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/9.jpg)
Decrypting with Custom Key
Decrypting with the key used for encryption will return this.
Our last string we encrypted was with a set key. Decrypting without the correct key will give us this.
![Page 10: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/10.jpg)
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.
![Page 11: Encryption PHP](https://reader034.fdocuments.us/reader034/viewer/2022052506/557646d8d8b42ac31b8b4e68/html5/thumbnails/11.jpg)
API ReferenceFor a better understanding of Validation in ProdigyView, visit the api by clicking on the link below.
PVSecurity
www.prodigyview.com
More Tutorials
For more tutorials, please visit:
http://www.prodigyview.com/tutorials