Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Apollo_aes_php

<?php
function HexStringToByte($hexString)
{
	$string = hex2bin($hexString);
	return $string;
}
function encrypt_string($string='', $key=''){
	$iv_size = 16;
	$iv = "1212121212121212";
    $blocksize = 16;
    $pad = $blocksize - (strlen($string) % $blocksize);
    $string = $string . str_repeat(chr($pad), $pad);
    return base64_encode($iv.openssl_encrypt($string, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv));
}
function decrypt_string($data, $key) {
    $ciphertext_dec = base64_decode($data) ; 
	$iv_size = 16;
    $iv_dec = substr($ciphertext_dec, 0, $iv_size);
    $ciphertext_dec = substr($ciphertext_dec, $iv_size);
    return openssl_decrypt($ciphertext_dec, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv_dec);
}

//$ciphertext = encrypt_string('Neeraj',HexStringToByte('0A6D4D8794371FC45B1E85368E38BE75'));
//print_r($ciphertext);
$ds = decrypt_string("jhI5nAdyb1qOEjmcB3JvWkrXzfs0jaJJIVMgqaElpdQ=",HexStringToByte('0A6D4D8794371FC45B1E85368E38BE75'));
print_r($ds);
exit;

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.