dongzhihong3940 2013-06-19 19:35
浏览 45

将Laravel密码迁移到Ruby

I'm having trouble figuring out how to do this.
Laravel uses the PHP crypt function. I'm not sure what the equivalent is in Ruby.
My passwords are hashed with a $2a hash as well, if that makes a difference.

This is Laravel's function

public static function check($value, $hash)
{   
    return crypt($value, $hash) === $hash;
}

I've tried Bcrypt::Password.new as well as String#crypt but I can't seem to get them to work.

Example password $2a$08$WJZWRyljoJGx.qunOGuGLeDaOn/Q3ShEvGxTkx3csWXqWUF21GhBe from the database and the real was 123456

  • 写回答

2条回答 默认 最新

  • duanqinjiao5244 2013-06-19 19:37
    关注

    Sorry about that. I just figured out how it worked after posting.

    The solution was BCrypt::Password.new('$2a$08$WJZWRyljoJGx.qunOGuGLeDaOn/Q3ShEvGxTkx3csWXqWUF21GhBe') == '123456'

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思