Merge branch 'master' of bitbucket.org:venbaittech/sparqapi
This commit is contained in:
commit
12867c2dd4
@ -49,10 +49,13 @@ class Welcome extends CI_Controller {
|
|||||||
$data = $this->input->get('dat');
|
$data = $this->input->get('dat');
|
||||||
if($data)
|
if($data)
|
||||||
{
|
{
|
||||||
|
// $data = 'vdo/20221031/1010/random';
|
||||||
// $uri = custom_encryption::encode($data);die();
|
// $uri = custom_encryption::encode($data);
|
||||||
|
|
||||||
$uri = custom_encryption::decode($data);
|
$uri = custom_encryption::decode($data);
|
||||||
// echo $uri;
|
// echo $uri;
|
||||||
|
// die();
|
||||||
|
|
||||||
$uri = explode('/',$uri);
|
$uri = explode('/',$uri);
|
||||||
// print_r($uri);die();
|
// print_r($uri);die();
|
||||||
$pd_id = $uri[2];
|
$pd_id = $uri[2];
|
||||||
|
|||||||
@ -18,7 +18,8 @@ class custom_encryption
|
|||||||
|
|
||||||
|
|
||||||
// Store cipher method
|
// Store cipher method
|
||||||
static private $ciphering = "BF-CBC";
|
static private $ciphering = "AES-256-CBC";
|
||||||
|
static private $key = "Awuc64pVpcB9xf";
|
||||||
public static function encode($str)
|
public static function encode($str)
|
||||||
{
|
{
|
||||||
$string_to_encrypt = $str;
|
$string_to_encrypt = $str;
|
||||||
@ -30,12 +31,13 @@ class custom_encryption
|
|||||||
// echo '$iv_length-'.$iv_length;
|
// echo '$iv_length-'.$iv_length;
|
||||||
// Use random_bytes() function which gives
|
// Use random_bytes() function which gives
|
||||||
// randomly 16 digit values
|
// randomly 16 digit values
|
||||||
$encryption_iv = random_bytes($iv_length);
|
// $encryption_iv = random_bytes($iv_length);
|
||||||
|
$encryption_iv = openssl_random_pseudo_bytes($iv_length);
|
||||||
// echo '$encryption_iv-'.$encryption_iv;
|
// echo '$encryption_iv-'.$encryption_iv;
|
||||||
|
|
||||||
// Alternatively, we can use any 16 digit
|
// Alternatively, we can use any 16 digit
|
||||||
// characters or numeric for iv
|
// characters or numeric for iv
|
||||||
$encryption_key = openssl_digest(php_uname(), 'MD5', TRUE);
|
$encryption_key = openssl_digest(SELF::$key, 'MD5', TRUE);
|
||||||
// echo '$encryption_key='.$encryption_key;
|
// echo '$encryption_key='.$encryption_key;
|
||||||
|
|
||||||
// Encryption of string process starts
|
// Encryption of string process starts
|
||||||
@ -44,7 +46,9 @@ class custom_encryption
|
|||||||
|
|
||||||
// Display the encrypted string
|
// Display the encrypted string
|
||||||
// echo "Encrypted String: " . $encryption . "\n";
|
// echo "Encrypted String: " . $encryption . "\n";
|
||||||
return base64_encode($encryption.'.'.$encryption_iv);
|
return base64_encode($encryption.'.'.base64_encode($encryption_iv));
|
||||||
|
|
||||||
|
// return base64_encode(openssl_encrypt($data, $this->method, $this->key, 0, $iv) . $this->separator . base64_encode($iv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -64,16 +68,16 @@ class custom_encryption
|
|||||||
// Used random_bytes() which gives randomly
|
// Used random_bytes() which gives randomly
|
||||||
// 16 digit values
|
// 16 digit values
|
||||||
// $decryption_iv = random_bytes($iv_length);
|
// $decryption_iv = random_bytes($iv_length);
|
||||||
$decryption_iv = $received_data[1];
|
$decryption_iv = base64_decode($received_data[1]);
|
||||||
// echo '$decryption_iv-'.$decryption_iv;
|
// echo '$decryption_iv-'.$decryption_iv;
|
||||||
|
|
||||||
// Store the decryption key
|
// Store the decryption key
|
||||||
$decryption_key = openssl_digest(php_uname(), 'MD5', TRUE);
|
$decryption_key = openssl_digest(SELF::$key, 'MD5', TRUE);
|
||||||
// echo '$encryption_key='.$decryption_key;
|
// echo '$encryption_key='.$decryption_key;
|
||||||
|
|
||||||
// Descrypt the string
|
// Descrypt the string
|
||||||
$decryption = openssl_decrypt ($str, SELF::$ciphering,
|
$decryption = openssl_decrypt ($str, SELF::$ciphering,
|
||||||
$decryption_key, $options, $decryption_iv);
|
$decryption_key, $options, ($decryption_iv));
|
||||||
|
|
||||||
// Display the decrypted string
|
// Display the decrypted string
|
||||||
// echo "Decrypted String: " . $decryption;
|
// echo "Decrypted String: " . $decryption;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user