All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.young.security.all.EncrypMD5 Maven / Gradle / Ivy

The newest version!
package com.young.security.all;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class EncrypMD5 {
	
	public byte[] eccrypt(String info) throws NoSuchAlgorithmException{
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		byte[] srcBytes = info.getBytes();
		//使用srcBytes更新摘要
		md5.update(srcBytes);
		//完成哈希计算,得到result
		byte[] resultBytes = md5.digest();
		return resultBytes;
	}
	
	
	public static void main(String args[]) throws NoSuchAlgorithmException{
		String msg = "郭德纲-精品相声技术";
		EncrypMD5 md5 = new EncrypMD5();
		byte[] resultBytes = md5.eccrypt(msg);
		
		System.out.println("密文是:" + new String(resultBytes));
		System.out.println("明文是:" + msg);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy