• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why my hash value comparison is false?  RSS feed

 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys. What I am doing wrong? I thought I generate salt for a user then get hash, then compare this with password input and the user salt to make them equal.
My hash values are not comparing to be equal..please help

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing that looks suspicious about your code is that the getSalt() method computes a new random salt every time that you call it.

That's probably the cause of the problems. you should compute a new salt once, and then use that computed value, instead of computing a new value each time in getSalt().
 
Campbell Ritchie
Marshal
Posts: 56541
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Paweł Baczyński
Bartender
Posts: 2083
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's offtopic and nitpicky...

Instead ofyou could write
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot guys..and glad to be here
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!