用MD5对密码进行加密

package com.yong.bin.md5;

import java.math.BigInteger;
import java.security.MessageDigest;

public class App {

	public String encrypt(String password) {
		MessageDigest md;
		try {
			md = MessageDigest.getInstance("MD5");
			md.update(password.getBytes());
			String pwd = new BigInteger(1, md.digest()).toString(16);
			return pwd;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return password;

	}

	public static void main(String[] args) {
		App app = new App();
		String pwd = app.encrypt("123456");
		System.out.println(pwd);
	}
}

 

你可能感兴趣的:(MD5)