Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Password comparison

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am implementing a simple authentication module. I am using a mySQL Db where the user password is stored using one-way encryption SHA-1. The password is stored as a BLOB in the DB.
Then in my Java App I am trying to valide the user entered password against the password in the DB :


This code always fails and I don't know why. Please help

Thanks.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually difficult to dignose. One idea may be to view the bytes in a hex editor. If I remeber correctly, the value in the DB should have {SHA-1} at the start in both instances, make sure it does. There is also the possibility the database value is corrupted, we recently had an error where it was able to encode a password twice. Maybe try writing the value again.
 
raphael Bereh
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it !
The mySQl SHA-1 return a Hex encoded byte array, so hex - encoding the bytes from MessageDisgester solves the issue.

Thanks .
 
Looky! I'm being abducted by space aliens! Me and this tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic