3
내가 bcrypt - 루비 보석을 시도하고 있었다 확인이 난 임의의 암호를 생성하고bcrypt 루비 암호 생성 및
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)
코드는 '같지 않다'대신 인쇄를 계속 확인하려면 다음 코드를 작성 '같은'. 내가 어디로 잘못 가고 있니? 고마워요 :)
참고. 다음과 같이 간단하게해야합니다 :'def encrypt_token (tok); BCrypt :: Password.create (tok); end' – Phrogz
죄송합니다, 저는 루비를 처음 접했습니다. 아직 코딩 규칙을 배우고 있습니다. –