• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

Java Generate MD5 Hash in Java

Status
Not open for further replies.

sQuo

~ KillmeMories ~
Shadow
User
Joined
Oct 16, 2011
Messages
5,851
Reputation
0
Reaction score
22,904
Points
688
Credits
0
‎13 Years of Service‎
24%
Here's the simple java security tutorial on generating MD5 hash of input text using java.security API functions.

Code:
>import java.security.MessageDigest;

public class MD5Class
{
 public static void main(String args[]) throws Exception
 {
   String input = "test text";
  
   MessageDigest m = MessageDigest.getInstance("MD5");
   m.update(input.getBytes("UTF8"));
   byte s[] = m.digest();
   String result = "";
  
   for (int i = 0; i     {
     result += Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6);
   }

   System.out.println("MD5 Hash of input text" + input);
   System.out.println(result);
 }
}
 
Status
Not open for further replies.
Back
Top