程序密码加密问题

一般加密都利用MD5加密,因为这是单向加密,不可逆,不过有MD5网站收藏了很多反加密的信息,可以有一定概率的破解,其最好的网站是http://wwwNaNd5.com/

import java.security.MessageDigest;

import java.security.NoSuchAlgorithmException;

 

 

public class Demo {

         public static void main(String[] args) throws Exception {

                   MessageDigest  digest = MessageDigest.getInstance("MD5");

                   String pwd = "123456";

                   byte[]  bytes = digest.digest(pwd.getBytes());

                   StringBuffer sb = new  StringBuffer();

                   for(int i = 0;i<bytes.length;i++){

                            String s = Integer.toHexString(0xff&bytes[i]);

                           

                            if(s.length()==1){

                                     sb.append("0"+s);

                            }else{

                                     sb.append(s);

                            }

                   }

                   System.out.println(sb.toString());

         }

}

你可能感兴趣的:(程序密码加密问题)