私はbcrypt-rubygemを試していましたが、ランダムなパスワードを生成して検証するために次のコードを記述しました
require 'bcrypt'
require 'securerandom'
def encrypt_token(tok)
BCrypt::Password.create(tok)
end
def check_token(enc,tok)
g = BCrypt::Password.new(enc)
if tok==g
puts 'equal'
else
puts 'not equal'
end
end
s = SecureRandom.hex(12)
puts s
e = encrypt_token(s)
puts e
check_token(e,s)
コードは、「等しい」ではなく「等しくない」を出力し続けます。どこが間違っているのですか?ありがとう :)