Reimplement ASP.NET Membership and User Password Hashing in Ruby

前端 未结 4 1165
-上瘾入骨i
-上瘾入骨i 2020-12-05 12:11

I have a large database of users (~200,000) that I\'m transferring from a ASP.NET application to a Ruby on Rails application. I don\'t really want to ask every user to rese

4条回答
  •  感情败类
    2020-12-05 12:54

    You need to unencode the salt to convert it back to it's byte representation and then concatenate that with the password to get the hashed password value. You're using the encoding salt string directly (which is a different salt) and thus it is hashing to something different.

    require "base64"
    require "digest/sha1"
    password = "password"
    salt = Base64.decode64("1ptFxHq7ALe7yXIQDdzQ9Q==")
    concat = salt+password
    sha1 = Digest::SHA1.digest(concat)
    encoded = Base64.encode64(sha1)
    puts encoded
    

提交回复
热议问题