encryption and decryption in codeigniter
Note* : You might require to load driver if no driver is loaded
$this->encryption->initialize(
array(
'driver' => 'openssl',
'cipher' => 'aes-256',
'mode' => 'ctr'
)
);
STEP 1: Load a encryption library
$this->load->library('encryption');
STEP 2: Create a encryption key for a config file application/config/config.php
$this->encryption->create_key(16);
############### OR #############
bin2hex($this->encryption->create_key(16)); // For more user friendly cipher text
Add this key inside the config file
$config['encryption_key'] = hex2bin(<your hex-encoded key>);
STEP 3: For encypt a plain text to cipher text
$plain_text = 'This is a plain-text message!';
$ciphertext = $this->encryption->encrypt($plain_text);
STEP 4: Decrypt Cipher text to plain text
// Outputs: This is a plain-text message!
echo $this->encryption->decrypt($ciphertext);
Also in PHP:
- basic code for file upload in php
- encryption and decryption in codeigniter
- dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib Referenced from: /usr/local/bin/php Reason: image not found zsh: abort bin/console sw:cache:clear
- clear cache function in laravel route
- cancel stripe subscription php
- acf form update post
- Laravel 8 seed
- convert request image as base64 string php
- create new laravel project
- fetch visitor ip address php
- Artisan::call('db:seed', array('--class' => 'YourSeeder Class'));
- currentdate timestamp php
- change max_execution_time php on script
- check string in php
- 1,458.00 to save as float php
- refresh php
- TreeBuilder::getRootNode()" before creating the root node is not supported, migrate to the new constructor signature instead.
- custom widget area wordpress
- array size php
- "$_HEADER" php
- difference entre deux date php
- check if string contains substring at the start php
- artisan cache command in laravel
- dot after each character php