CodeIgniter Forums

Full Version: Problem in AES
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
Why when i use below code for decryption,result is empty
PHP Code:
$this->load->library('encryption');
        
$this->encryption->initialize(
            array(
                
'cipher' => 'aes-256',
                
'mode' => 'cbc',
                
'key' => 'RfUjXn2r5u8x!A%D*G-KaPdSgVkYp3s6'
            
)
        );
        echo 
$this->encryption->decrypt('R0gyV2NwQEJ5ZVZKODVnaHYEbS37syFYTcQNdwMXMQo='); 

But when i use below code,it return correct result:
PHP Code:
function EncryptAES($message$key){
            
$ivsize openssl_cipher_iv_length('aes-256-cbc');
            
$iv openssl_random_pseudo_bytes($ivsize);
            
$ciphertext openssl_encrypt($message,'aes-256-cbc',$key,OPENSSL_RAW_DATA,$iv);

            return 
$iv $ciphertext;
      } 
Result must be omid
You can decrypt it in https://www.devglan.com/online-tools/aes...decryption
Thanks