org.apache.commons.codec.digest
Class DigestUtils
java.lang.Object org.apache.commons.codec.digest.DigestUtils
static String
md5Hex(String data)
Calculates the MD5 digest and returns the value as a 32 character hex string.
apache commons codec下载:http://commons.apache.org/proper/commons-codec/download_codec.cgi
实现方法:
- import org.apache.commons.codec.digest.*;
- public class md5another {
- public void md5create(String input) {
- System.out.print("32bit result:" + DigestUtils.md5Hex(input) + "\n");
- System.out.print("16bit result:"
- + DigestUtils.md5Hex(input).substring(8, 24) + "\n");
- }
- public static void main(String[] args) {
- md5another a = new md5another();
- a.md5create("nenew");
- }
- }
Comments (2)
Comments are closed.