Skip to content

Instantly share code, notes, and snippets.

Created October 24, 2016 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/210c9c13a167080765306e85a729ef36 to your computer and use it in GitHub Desktop.
Save anonymous/210c9c13a167080765306e85a729ef36 to your computer and use it in GitHub Desktop.
Série RestServer - Helper passw_service
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('EncryptPassw'))
{
/**
* Esse método criptografa a senha
* @package helpers
* @subpackage Password Services
* @param string $passw Senha
* @return string
*/
function EncryptPassw($passw)
{
if(is_null($passw))
return null;
$passw_encrypted = password_hash($passw, PASSWORD_BCRYPT);
if($passw_encrypted)
return $passw_encrypted;
else
return $passw;
}
}
if ( ! function_exists('DecryptPassw'))
{
/**
* Esse método verifica se as senhas são iguais
* @package helpers
* @subpackage Password Services
* @param string $passw Senha do usuário sem criptografia
* @param string $passw_encrypted Senha do usuário criptografada
* @return boolean
*/
function DecryptPassw($passw, $passw_encrypted)
{
if(is_null($passw) || is_null($passw_encrypted))
return false;
$verify = password_verify($passw,$passw_encrypted);
return $verify;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment