Search
 
SCRIPT & CODE EXAMPLE
 

PHP

fakher ul islam khan

function CryptoJSAesEncrypt($passphrase, $plain_text){

    $salt = openssl_random_pseudo_bytes(256);
    $iv = openssl_random_pseudo_bytes(16);
    //on PHP7 can use random_bytes() istead openssl_random_pseudo_bytes()
    //or PHP5x see : https://github.com/paragonie/random_compat

    $iterations = 999;  
    $key = hash_pbkdf2("sha512", $passphrase, $salt, $iterations, 64);

    $encrypted_data = openssl_encrypt($plain_text, 'aes-256-cbc', hex2bin($key), OPENSSL_RAW_DATA, $iv);

    $data = array("ciphertext" => base64_encode($encrypted_data), "iv" => bin2hex($iv), "salt" => bin2hex($salt));
    return json_encode($data);
}

$string_json_fromPHP = CryptoJSAesEncrypt("your passphrase", "your plain text");
Comment

PREVIOUS NEXT
Code Example
Php :: php header x forwarder for 
Php :: toggle between login and logout buttons php 
Php :: how to give optional parameter in route 
Php :: how to send mail in laravel 
Php :: filter array in php with passing extra params 
Php :: php get 
Php :: how to make model and controller in laravel 
Php :: cara membuat looping table dengan php 
Php :: create excel file using php] 
Php :: codeigniter 3 where not in 
Php :: laravel route required parameters 
Php :: php add get to link 
Php :: php call constant in class 
Php :: json_encode alternative 
Php :: parse json nested array form url in php 
Php :: dispatch job with queue name in laravel 
Php :: db seed in controller 
Php :: laravel fontawesome 
Php :: Invalid argument supplied for foreach() in C 
Php :: symfony form get errors 
Php :: laravel hash 
Php :: wordpress change post format 
Php :: function default value 
Php :: display money format php 
Php :: php add to array 
Php :: php url exists valid 
Php :: php list *files 
Php :: acf wordpress loop through and display blog posts order by date and type 
Php :: laravel 8 carbon if date is today 
Php :: getimagesize php 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =