Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:29:30+00:00 2026-06-07T10:29:30+00:00

for some reason the, authentication fails. However if i print the hashes to stdout,

  • 0

for some reason the, authentication fails. However if i print the hashes to stdout, it’s identical. Anyone have any ideas what’s wrong?

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

The password file looks like this :

bob:$2a$10$1xNjCZxjv0R06qUm1lQEEeZ1uKuZ9ELQIkT2h5/TxCI9eHDurr.dW
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:29:31+00:00Added an answer on June 7, 2026 at 10:29 am

    The lines returned by File#each include the newline at the end of the line, so your passwordCheck variable has a trailing newline but the bcrypt generated hash doesn’t.

    You can remove the newline with chomp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added username to a devise authentication setup, and for some reason, it's
For some reason I can't detect I can't set a z index for any
For some reason I can't get Basic Authentication to work using PHP on my
I have the following task: download a file using HTTPS and authentication. Indy seems
I have the IP address, but for some reason I can get the name
For some reason neither the accepted answer nor any others work for me for
I have a web application, and for some reason which I cannot figure out,
For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
for some reason when I try to call CocoaAsyncSocket's onSocket:didReadData:withTag method, it's failing and
For some reason there's a variable called d that is defined immediately after I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.