1.MD5加密:
- public static String md64Encode(String Password){
- String newPassword = null;
- try {
- MessageDigest md5 = MessageDigest.getInstance("MD5");
- BASE64Encoder base64en = new BASE64Encoder();
- newPassword = base64en.encode(md5.digest(Password.getBytes()));
- System.out.println("加密后为:"+newPassword);
- } catch (NoSuchAlgorithmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return newPassword;
- }
2.DZ加密方式
方法:DZ加密就是 MD5(MD5(password)+时间戳);
- public static String DZEncryption(String Password){
- String newPassword = null;
- try {
- MessageDigest md5 = MessageDigest.getInstance("MD5");
- BASE64Encoder base64en = new BASE64Encoder();
- newPassword = base64en.encode(md5.digest(Password.getBytes()));
- newPassword = newPassword+System.currentTimeMillis();
- newPassword = base64en.encode(md5.digest(newPassword.getBytes()));
- } catch (NoSuchAlgorithmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return newPassword;
- }
或者 调用MD5方法
- MD5Util.md64Encode(MD5Util.md64Encode("666666")+System.currentTimeMillis())
3.JAVA中的时间戳
System.currentTimeMillis();