<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      MD5算法(看在你是女孩的份上,給你一個吧)

      [摘要]public String MD5(String sInput) throws Exception String algorithm=""; //輸入不能為空 if(sInp...
      public String MD5(String sInput)
       throws Exception{
       
       String algorithm="";
       //輸入不能為空
       if(sInput.trim()==null){
      return "null";
       }
       
       //指定采用MD5算法
       try{
      algorithm=System.getProperty("MD5.algorithm","MD5");
       }catch(SecurityException se){
       }
       
       //定義MessageDigest對象
       MessageDigest md=MessageDigest.getInstance(algorithm);
       
       //按照系統缺省的字符編碼方式把sInput 轉換成字節,并把結果存到一新的字節數組buffer中
       byte buffer[]=sInput.getBytes();
       
       //從指定的字節數組buffer的偏移量0開始,用指定的字節數組修改由sInput生成摘要
       //count為從 0 開始用的字節數長度。
       for(int count=0;count<sInput.length();count++)
       {
      md.update(buffer,0,count);
       }
       
       //通過執行最后的諸如填充的操作完成散列碼的計算。 在調用之后復位該摘要
       //返回存放結果散列值的字節數組bDigest
       byte bDigest[]=md.digest();
       
       //將bDigest轉換為大整數bi
       BigInteger bi=new BigInteger(bDigest);
       
       //返回bi字符串表示,即最終的編碼結果
       return(bi.toString(16));
       }
       


      日韩精品一区二区三区高清