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 7834817

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:20:11+00:00 2026-06-02T13:20:11+00:00

I am no security expert and happen not to give it much thought since

  • 0

I am no security expert and happen not to give it much thought since most of my app run on local intranet so who
cares about security? 🙂

But actually, I am trying to make it right.

I have setup JDBC realm on glassfish and I am saving my password now with MD5 hashing using this code from the internet.

public static String getMD5(String input) 
{
    try
    {
      MessageDigest md = MessageDigest.getInstance("MD5");
      md.update(input.getBytes());

      byte byteData[] = md.digest();

      //convert the byte to hex format method 1
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < byteData.length; i++)
      {
        sb.append(Integer.toString((byteData[i] & 0xff) + 0x100,
                                   16).substring(1));
      }
      return sb.toString();
    }
    catch (NoSuchAlgorithmException e)
    {
      throw new RuntimeException(e);
    }
}

Now my question is, during change password use case… is it just comparing if the hash are equal to validate if the password
entered is the same from what is in my DB like this code below?

public static void main(String[] args)
throws NoSuchAlgorithmException
{
String currentPassword = "java";
String inputValue = "java1";

String string1 = getMD5(currentPassword);
String string2 = getMD5(inputValue);

System.out.println("Is equal = " + string1.equals(string2));
}

I have read somewhere that MD5 is a one way hashing so I cannot decrypt back the password to string?

Sorry, if my question is too simple but I’d just like to confirm my understanding?

Thanks

  • 0 0 Answers
  • 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-02T13:20:19+00:00Added an answer on June 2, 2026 at 1:20 pm

    The same password will always hash to the same value, so you can do the check you are talking about. Also, in general a hash function cannot be reversed. That is, given a hash of some password, you cannot deduce the password given the hash. However MD5 has been broken, so you should use some other hash function instead (like SHA-256). It’s also worth noting that to really do this securely, you should salt the passwords before your hash them to prevent rainbow-table attacks.

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

Sidebar

Related Questions

Lead in ... I'm not an expert, by far, in application security via SSL,
I'm not a security expert, so I'm looking for people to poke gaping holes
I am no expert in network security, so pardon if this question is not
I'm not a security expert by any means, but I favor creating REST-style web
For security reasons, several articles recommend do not cache pages. So I usually put
For security reasons (I'm a developer) I do not have command line access to
I am by no means a security expert or even a novice. I'm a
For a long time, I've wanted to become a security expert. In fact, I've
I have two decades SQL experience, but not specifically with Oracle. An 'Oracle expert'
I have recently watched this video of a Finnish internet security expert. Somewhere around

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.