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

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




Together We Can Simplify The World
Just a Web Code Solution

encrypt and decrypt password using php


 376

 PHP


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');

?>


  
The power of the user (%)
7%



The most helpful PHP solutions

detect browser phpdetect browser phpPHP

Click to see more ...

  2K     366

create QR code phpcreate QR code phpPHP

Click to see more ...

  1.6K     263

create relative date phpcreate relative date phpPHP

Click to see more ...

  1.1K     214

detect ie phpdetect ie phpPHP

Click to see more ...

  652     209

get current url phpget current url phpPHP

Click to see more ...

  516     189

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

Click to see more ...

  421     169

get meta tag phpget meta tag phpPHP

Click to see more ...

  347     129

detect speed internet phpdetect speed internet phpPHP

Click to see more ...

  321     105

How can I create an object using php ?How can I create an object using php ?PHP

Click to see more ...

  285     104

How to connect to MySQL database using PHP ?How to connect to MySQL database using PHP ?PHP

Click to see more ...

  150     72