• Post Reply Bookmark Topic Watch Topic
  • New Topic

Same input but one in char array and other in string: Giving different hashes!  RSS feed

 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am hashing a pass. Same input but one in char array and other in string: Giving different hashes!
Say i define char[] some="pass" and String s_ome="pass"; hashing it giving me different values...but if use string for both it matches...please tell me a way to remain the types as it is but to get same hashes

actually i am using and need to use Console read password....
thanks!

 
Stephan van Hulst
Saloon Keeper
Posts: 7972
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please show us how you're hashing the input, and what results you're getting.
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Please show us how you're hashing the input, and what results you're getting.


 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never never write == false or == true or similar. They are poor style and error‑prone because you might write = instead of ==.
Don't use underscores in variable names. Use camelCase.

What is values hash key? What does the bit about map mean? Why are you using so many Strings? What is hide pass? How do you manage to call toString() on it?
We cannot understand that method without knowing that information. Does that code actually compile?
 
Stephan van Hulst
Saloon Keeper
Posts: 7972
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mohammad,

The code you posted doesn't reflect your problem. Can you please post an SSCCE?
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Hi Mohammad,

The code you posted doesn't reflect your problem. Can you please post an SSCCE?


Sure I will have a read and try to follow the guide
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the problem

The password was not being set as per password policy..Can you please tell me how can I check if a least one of this special character is matched



I do not know how to make them match. the condition was never being set true thats why password not being set
 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Never never write == false or == true or similar. They are poor style and error‑prone because you might write = instead of ==.
Don't use underscores in variable names. Use camelCase.

What is values hash key? What does the bit about map mean? Why are you using so many Strings? What is hide pass? How do you manage to call toString() on it?
We cannot understand that method without knowing that information. Does that code actually compile?


but I need to check equality?
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not for boolean literals.
 
Stephan van Hulst
Saloon Keeper
Posts: 7972
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you need to supply a boolean value to the conditional statement. checkUser() already returns a boolean, so you don't need to add the == true part.

Anyway, why do you require special characters? you should allow many different kinds of passwords, not limit them. Requiring special characters is a mistake. The only requirement you should have for a password is a minimum length.
 
Stephan van Hulst
Saloon Keeper
Posts: 7972
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For proper authentication you should use an algorithm like bcrypt though.
 
Tim Harris
Ranch Hand
Posts: 57
3
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:Anyway, why do you require special characters? You should allow many different kinds of passwords, not limit them. Requiring special characters is a mistake. The only requirement you should have for a password is a minimum length.


Any time the issue of a password shows up, I feel obligated to show this xkcd comic:

 
Mohammad Ashari Rahman
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:No, you need to supply a boolean value to the conditional statement. checkUser() already returns a boolean, so you don't need to add the == true part.

Anyway, why do you require special characters? You should allow many different kinds of passwords, not limit them. Requiring special characters is a mistake. The only requirement you should have for a password is a minimum length.


My tutor demands it :>
 
Stephan van Hulst
Saloon Keeper
Posts: 7972
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're checking whether your entire password string matches some regular expression. You should change the regular expression so that the special character can be preceded and followed by any character, 0 or more times.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!