【问题标题】:Verifying Resftul Authentication through a Non Ruby App通过非 Ruby 应用程序验证 Resftul 身份验证
【发布时间】:2010-12-06 03:53:12
【问题描述】:

我正在尝试从 php 应用程序对 restful_authentication 进行身份验证,但是我知道它使用 SHA1(摘要--salt--password--RESTFUL_AUTH_KEY)。问题是无论我尝试多少,我都无法让哈希匹配。通读文档,我看到摘要只是 restful auth 密钥,但这就是我感到困惑的地方。除了使用 ruby​​ 之外,还有其他人能够找到一种方法来匹配散列密码吗?如果可以的话,该怎么做?

【问题讨论】:

    标签: php ruby security restful-authentication authentication


    【解决方案1】:

    这里是一个使用 php 的例子:

    <?php
    
    $password = 'SomePassword';
    $salt = 'saltHashFromDB';
    $sitekey = 'siteKeyFromConfig';
    
    function pwcrypt($password, $salt, $sitekey) {
      $digest = $sitekey;
      $i = 0;
      while ($i < 10) {
        $digest = sha1($digest.'--'.$salt.'--'.$password.'--'.$sitekey);
        $i++;
      }
      return $digest;
    }
    echo pwcrypt($password,$salt,$sitekey);
    ?>
    

    这是一个非常简单的示例,您应该能够基于此将其集成到您的应用程序中。我知道在 ruby​​ 代码中有大约 4 或 5 个函数,它一个接一个地调用来做同样的事情,把它放在一个地方应该更容易理解。

    如果您需要任何说明,请告诉我。

    谢谢,

    C4colo

    【讨论】:

      猜你喜欢
      • 2016-04-30
      • 2017-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-23
      • 1970-01-01
      • 2015-04-29
      相关资源
      最近更新 更多