how to generate md5 hash in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muralihkrishna
    New Member
    • Aug 2007
    • 3

    how to generate md5 hash in java

    hi friends,
    i m involved in a project in which the password is encrypted using md5 algorithm(passw ord()) in mysql database.
    to authenticate whether the user is authorized or not, i have to encrypt his entered password and check with the database. can anyone help me how to encrypt the password in java and compare it with database.

    thanx in advance.
    Murali.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Have a look at the MessageDigest class.

    kind regards,

    Jos

    Comment

    • praveen2gupta
      New Member
      • May 2007
      • 200

      #3
      Originally posted by muralihkrishna
      hi friends,
      i m involved in a project in which the password is encrypted using md5 algorithm(passw ord()) in mysql database.
      to authenticate whether the user is authorized or not, i have to encrypt his entered password and check with the database. can anyone help me how to encrypt the password in java and compare it with database.

      thanx in advance.
      Murali.
      Hi
      you should compare password after receiving password from database and decode it with the algorathem. Now it will be in the text form. After that you can store this in the string and can use equals method of string class.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by praveen2gupta
        Hi
        you should compare password after receiving password from database and decode it with the algorathem. Now it will be in the text form. After that you can store this in the string and can use equals method of string class.
        There's no reason to decode an encrypted password; simple encrypt two passwords
        and if the encrypted passwords are equal, (most likely) the passwords themselves
        are equal as well. It's called 'one way encryption'.

        kind regards,

        Jos

        Comment

        • nkumar
          New Member
          • Aug 2007
          • 4

          #5
          try this,

          < code deleted >

          Please don't spoonfeed complete code; we don't do that here. Please read the
          guidelines of these forums (fora?) See the 'Help' link at the top right of this page.

          kind regards,

          Jos

          Comment

          • muralihkrishna
            New Member
            • Aug 2007
            • 3

            #6
            Originally posted by JosAH
            Have a look at the MessageDigest class.

            kind regards,

            Jos
            Thanx for ur help mate. its really useful a advice

            Comment

            Working...