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

encrypt and decrypt password using php


 399

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

?>


By     Created   
The power of the user (%)
8%



The most helpful PHP solutions

detect browser phpdetect browser phpPHP

Click to see more ...

  3.1K     382

create QR code phpcreate QR code phpPHP

Click to see more ...

  2.1K     273

delete array item phpdelete array item phpPHP

Click to see more ...

  1.7K     227

create relative date phpcreate relative date phpPHP

Click to see more ...

  1.3K     215

detect ie phpdetect ie phpPHP

Click to see more ...

  1K     209

get current url phpget current url phpPHP

Click to see more ...

  608     188

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

Click to see more ...

  511     168

get meta tag phpget meta tag phpPHP

Click to see more ...

  429     128

detect speed internet phpdetect speed internet phpPHP

Click to see more ...

  405     106

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

Click to see more ...

  369     103