PHP encrypt and decrypt password php - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution
join us

encrypt and decrypt password using php


 600

Show ResultPHP


2

<?php

function encrypt_decrypt($string_enc, $action='encrypt') {
$encrypt_method = "AES-256-CBC";
$user_secret_key = 'AA74CDCC2BBRT935136HH7B63C27'; // user define private key
$user_secret_iv = '5fgf5HJ5g27'; // user define secret key
$key = hash('sha256', $user_secret_key);
$iv = substr(hash('sha256', $user_secret_iv), 0, 16); // sha256 is hash_hmac_algo
if( $action == 'encrypt' ) {
$output = openssl_encrypt($string_enc, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
}
else if( $action == 'decrypt' ){
$output = openssl_decrypt(base64_decode($string_enc), $encrypt_method, $key, 0, $iv);
}
return $output;
}

echo "Your Encrypted password is => ". $pwd = encrypt_decrypt('spaceo', 'encrypt');
echo '<br/>';
echo "Your Decrypted password is => ". encrypt_decrypt($pwd, 'decrypt');

?>


By        
The power of the user (%)
13%



The most helpful PHP solutions

detect browser phpdetect browser phpPHP

Click to see more ...

  4.6K     408

create QR code phpcreate QR code phpPHP

Click to see more ...

  3K     289

create relative date phpcreate relative date phpPHP

Click to see more ...

  2.2K     264

drag and drop upload file using phpdrag and drop upload file using phpPHP

Click to see more ...

  2.7K     253

delete array item phpdelete array item phpPHP

Click to see more ...

  2.4K     245

detect ie phpdetect ie phpPHP

Click to see more ...

  1.6K     213

detect speed internet phpdetect speed internet phpPHP

Click to see more ...

  1.6K     198

get current url phpget current url phpPHP

Click to see more ...

  1.7K     197

get meta tag phpget meta tag phpPHP

Click to see more ...

  1.4K     193

Get real client country using php ?Get real client country using php ?PHP

Click to see more ...

  1.4K     181

Welcome aboard!
We are happy you are here and
wish you good net-raft!