Tags: PHP
I've been dealing more and more with user authentication and these short functions have helped me store their information securely.
function hashword($string, $salt){
$string = crypt($string,$salt);
return $string;
}
function encrypt($string,$key){
$string = rtrim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_ECB)));
return $string;
}
function decrypt($string, $key){
$string = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, base64_decode($string), MCRYPT_MODE_ECB));
return $string;
}
©2023, kirillsimin.com