欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

加密用户密码

程序员文章站 2022-07-13 21:39:36
...

 

 

 

 

	public static String encryptPassword(String userName, String password)
	{
		try
		{
			String key1 = "1jjejduuhjdjdHDUEHWHd3ehgfidhwh23hHJCRIOI4HDHDHFKHFD3dhdhrg2djsHSDFHFEDJGW";
			String key2 = "r347djejDETahe3j%3jd*%%2DDE223fdhahfh%^@21hdhfhzhdDFQ3hH7eh32hdE#@sdqhqhde";
			String key3 = "[email protected]/#21ssdEdhawehrcyzhzeje2#@SDajw2D2sjzahd3#dSa";
			String str = key1 + userName + key2 + password + key3;
			MessageDigest alg = MessageDigest.getInstance("MD5");
			byte[] b = str.getBytes();
			alg.reset();
			alg.update(b);
			byte[] hash = alg.digest();
			String d = "";
			for (int i = 0; i < hash.length; i++)
			{
				int v = hash[i] & 0xFF;
				if (v < 16)
				{
					d += "0";
				}
				d += Integer.toString(v, 16).toUpperCase();
			}
			return d;
		}
		catch (NoSuchAlgorithmException e)
		{
			return null;
		}
	}