php - Sentry 使用什么类型的加密

标签 php encryption laravel laravel-4 cartalyst-sentry

我正在为我创建的现有 Web 应用程序构建 iOS 应用程序。该 Web 应用程序使用 Laravel 和 Sentry 来加密密码。必须能够从 iOS 应用程序创建新用户。 Web 应用程序与之通信的服务器是用 PHP 编写的,但不使用 Laravel 或 Sentry。 我唯一需要的哨兵功能是他们用来加密密码的功能。

哨兵使用什么函数来哈希密码?我说的是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;
}

关于php - Sentry 使用什么类型的加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20804298/

相关文章:

c# - 链式 GZipStream/DeflateStream 和 CryptoStream (AES) 在读取时中断

Laravel api 路由不起作用 - 404

php - 使用 Amazon RDS MySQL 数据库托管在 Heroku 上的 Laravel 应用程序导致连接超时

php - Codeigniter - 只能在 autoload.php 中加载模型

php - 使用 codeigniter 在数据库中存储注销时间

php - 在 Redis 上安全存储 PHP session 的身份验证 key

javascript - 无法在 Laravel Blade 文件中使用 jQuery

android - sqlcipher_export 没有导出我的表

java - 如何以编程方式发送加密电子邮件(从自动化过程)

php - 尽管 Laravel 中的 token 正确,Ajax 调用仍返回 419 错误