1234567891011121314151617181920212223242526272829303132333435 |
- package com.sinosoft.am.userUtil;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import org.apache.commons.net.util.Base64;
- public class UserUtil {
- public static String md5(String msg){
- String result = "";
- if(msg==null){
- return result;
- }
- try {
- MessageDigest md = MessageDigest.getInstance("MD5");
- MessageDigest.getInstance("MD5");
- byte[] output = md.digest(msg.getBytes());
- System.out.println(output.toString());
- result = Base64.encodeBase64String(output).trim();
- //System.out.println(result);
- return result;
-
- } catch (NoSuchAlgorithmException e) {
- e.printStackTrace();
- }
-
- return result;
-
- }
- public static void main(String[] args){
- System.out.println(md5("nwyj123456"));
- //System.out.println(md5("abcsssssssssssxxxxx")); wZ1sb/mFufbA99q6evnD4A==
- }
- }
|