Created
October 24, 2016 20:41
-
-
Save anonymous/210c9c13a167080765306e85a729ef36 to your computer and use it in GitHub Desktop.
Série RestServer - Helper passw_service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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