0
由於某種原因,認證失敗。但是,如果我打印散列到標準輸出,它是相同的。任何人有任何想法有什麼不對?比較bcrypt散列
if File.exists?(passwdFile)
File.open("#{passwdFile}",'r').each do |account|
@account = account.split(':')
usernameCheck = @account[0] # Stored username
passwordCheck = @account[1] # Stored hashed password
if username == usernameCheck
# Create hash for given password to compare againts our stored one.
password_hash = BCrypt::Engine.hash_secret(password, password_salt)
puts "#{password_hash}"
puts "#{passwordCheck}"
if passwordCheck == password_hash
@log.info 'Successfull authentication'
return true
密碼文件看起來是這樣的:
bob:$2a$10$1xNjCZxjv0R06qUm1lQEEeZ1uKuZ9ELQIkT2h5/TxCI9eHDurr.dW
刪除換行符!謝謝! – daemonza 2012-07-11 07:48:42