我正在为我创建的现有Web应用程序构建iOS应用程序。该网络应用使用laravel和哨兵对密码进行加密。必须能够从iOS应用创建新用户。Web应用程序与之通信的服务器是用php编写的,但不使用laravel或哨兵。我唯一需要的哨兵功能是用于加密密码的哨兵功能。
岗哨使用什么函数来哈希密码?我说的是Cartalyst \ Sentry \ Hashing \ NativeHasher
我需要能够复制此功能,并在单独的php文件中使用它。
我找到了此链接:https : //github.com/cartalyst/sentry/blob/master/src/Cartalyst/Sentry/Hashing/NativeHasher.php
并且此代码可能是您想要的:
public function hash($string)
{
// Usually caused by an old PHP environment, see
// https://github.com/cartalyst/sentry/issues/98#issuecomment-12974603
// and https://github.com/ircmaxell/password_compat/issues/10
if (!function_exists('password_hash')) {
throw new \RuntimeException('The function password_hash() does not exist, your PHP environment is probably incompatible. Try running [vendor/ircmaxell/password-compat/version-test.php] to check compatibility or use an alternative hashing strategy.');
}
if (($hash = password_hash($string, PASSWORD_DEFAULT)) === false) {
throw new \RuntimeException('Error generating hash from string, your PHP environment is probably incompatible. Try running [vendor/ircmaxell/password-compat/version-test.php] to check compatibility or use an alternative hashing strategy.');
}
return $hash;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句