Re: Hashing Method in JSP
Hey, you can simply create an MD5 Hash in jsp by the use of the code below:
Code:
String str = "123456";
MessageDigest msgdigest = MessageDigest.getInstance("MD5");
msgdigest.update(str.getBytes());
byte[] digest = msgdigest.digest();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < digest.length; i++) {
str = Integer.toHexString(0xFF & digest[i]);
if (str.length() < 2) {
str = "0" + str;
}
sb.append(str);
}
out.print(sb.toString());
Re: Hashing Method in JSP
Hello, you can simply able to create a keyed Digest Using MD5 algorithm. As we know the keyed digest is the digest in which the secret key is used for making a digest for your buff of bytes. And it is also possible to use different keys for creating different digests. For getting reference you can simply make use of the code below:
Code:
public static byte[] getKeyedDigest(byte[] buff, byte[] key)
{
try
{
MessageDigest msgdigest = MessageDigest.getInstance("MD5");
msgdigest.update(buff);
return msgdigest.digest(key);
}
catch (NoSuchAlgorithmException nsae)
{
}
return null;
}
Re: Hashing Method in JSP
Hey, I have search regarding this and unable to get the details about it. But, I think if you refer the books below you will able to get the hashing method in JSP:
- JavaBeans: Developing Component Software in Java
- Java Secrets
- The Java Developer's Resource
- Concurrent Programming in Java: Design Principles and Patterns
- The Java Virtual Machine Specification
Re: Hashing Method in JSP
Hello, I am not having any knowledge about the hashing methods in java and jsp. But, you can simply able to find out all of the message digest algorithms by the use of the program below. For that it is necessary to make use of the services provided by all of the registered providers. And then the list which you will get can be used for the making MessageDigest object.
Code:
String[] names = getCryptoImpls("MessageDigest");