Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
Saloon Keeper
Posts: 12828
279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Please show us how you're hashing the input, and what results you're getting.



 
Marshal
Posts: 72487
315
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 12828
279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 72487
315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not for boolean literals.
 
Stephan van Hulst
Saloon Keeper
Posts: 12828
279
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 12828
279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For proper authentication you should use an algorithm like bcrypt though.
 
Ranch Hand
Posts: 57
3
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 12828
279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic