<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-26  評論-111  文章-19  trackbacks-0

    /*
     * Encrypt 字符串加密
     *
     * @author shiwei 2004-8-28
     */

    package com.snoics.base.util;
    /**
     * Encrypt 字符串加密
     * @author shiwei
     *
     */
    public class Encrypt {

        public Encrypt() {

        }

        /**
         * 加密字符串
         * @param encryptstring
         * @return String
         */
        public static String encrypt(String encryptstring){
         String newstring="";
         if(encryptstring.length()<1){
          return encryptstring;
         }else{
          String tempstring=StringClass.remove(encryptstring,0,(int)(encryptstring.length()/3));
          tempstring=StringClass.getConvertString(tempstring);
          encryptstring=StringClass.getConvertString(encryptstring);
          newstring=encrypt(encryptstring,tempstring);
          return newstring;
         }
        }
       
        /**
         * 普通加密字符串
         *
         * @param encryptstring1
         * @param encryptstring2
         * @return String
         */
        public static String encrypt(String encryptstring1, String encryptstring2) {
            int strcount = 0; //字符串ASCII碼的總和
            int newpasswordlength = 0; //生成的密碼長度
            int seed1 = 0; //種子
            int seed2 = 0;
            String str = "";
            String newpassword = ""; //生成的密碼
            char newchar;
            int newcharint = 0;
            int thechar = 0;

            str = encryptstring2 + encryptstring1;

            if (str.length() > 0) {
                for (int i = 0; i < str.length(); i++) {
                    strcount = strcount + str.charAt(i);
                }

                newpasswordlength = (strcount * strcount) / str.length() + str.length();

                int temp = 0;
                int temp2 = 0;
                while ((newpasswordlength <= 0) || (newpasswordlength > 100)) {
                    temp = temp + str.length();
                    temp2 = temp + temp2;
                    newpasswordlength = 100;
                }

                for (int i = 0; i < encryptstring1.length(); i++) {
                    seed1 = seed1 + encryptstring1.charAt(i);
                }
                for (int i = 0; i < encryptstring2.length(); i++) {
                    seed2 = seed2 + encryptstring2.charAt(i);
                }

                for (int i = 0; i < newpasswordlength; i++) {

                    if (i < str.length()) {
                        thechar = str.charAt(i);
                    } else {
                        thechar = str.charAt(i % (str.length() - 1))
                                + str.charAt((str.length() - 1)
                                        - (i % str.length()));
                    }
                    newcharint = thechar * (seed1 * (i + 1) + thechar);
                    newcharint = newString(newcharint);
                    newcharint = thechar * (seed2 * (i + 1) + thechar);
                    newcharint = newString(newcharint);
                    newchar = (char) newcharint;
                    newpassword = newpassword + String.valueOf(newchar);
                }
                newpassword = newpassword.substring((encryptstring2.length() + encryptstring1.length()) % 100);
                return (newpassword);
            } else {
                return ("空字符串不能被加密");
            }
        }

        private static int newString(int charint) {
            while ((charint > 127) || (charint < 32)) {
                while (charint > 127) {
                    charint = (charint - charint/2+1) / 2;
                    while(charint==60||charint==62||charint==34||charint==32||charint==39){
                     charint = charint + 1;
                    }
                }
                while (charint < 32) {
                    charint = (charint + charint/2-1) * 2;
                    while(charint==60||charint==62||charint==34||charint==32||charint==39){
                     charint = charint + 1;
                    }
                }
            }
            return (charint);
        }

        public static void main(String[] args) {
            String theusername = "1abc1";
            String thepassword = "1def1";
            String theusername1 = "1def1";
            String thepassword1 = "1abc1";
            String newstring=Encrypt.encrypt(theusername,thepassword);
            System.out.println("newstring="+newstring);
            String newstringa=Encrypt.encrypt(theusername1,thepassword1);
            System.out.println("newstringa="+newstringa);
            String newstring2=Encrypt.encrypt(newstring);
            System.out.println("newstring2="+newstring2);
            String newstring3=Encrypt.encrypt(newstring2);
            System.out.println("newstring3="+newstring3);
        }

    }


    執行結果:

    newstring=*?C4%;V[GKOoUX[_#i%ptvy)!!#01&c(46*o;=?y{?AB#4HI7%7LM:==U?@?AXBZFGHH`IJKfgO4QlmR7qrt::wxz=
    newstringa=(=A4$;TYDHLmTW[_#d#kpvx*!#-/$a(56)m89;vy@AB!2DE4$7LN::;P==?AYBXCDEE^IJKceL3NikR6opq89uvw;
    newstring2=ij887i)54)?!@A!!!Ab##eBf##ddd#efff#b#cadc#bc_!!]@
    newstring3=(qI}!+A!#z%%4?((
    posted on 2006-02-20 10:45 snoics 閱讀(1751) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 无码一区二区三区亚洲人妻| 9久久免费国产精品特黄| 内射无码专区久久亚洲| 国产福利电影一区二区三区,免费久久久久久久精 | 亚洲国产视频一区| 国产女高清在线看免费观看| 久久国产精品免费一区| 亚洲国产精品一区二区久| 亚洲 自拍 另类小说综合图区 | 久青草视频97国内免费影视| 亚洲国产精品白丝在线观看| 亚洲高清无码综合性爱视频| 51精品视频免费国产专区| 国产亚洲视频在线观看| 亚洲资源在线观看| 国产在线观看免费视频播放器| 久久久久成人精品免费播放动漫| 亚洲欧美国产精品专区久久| 亚洲AV无码精品色午夜在线观看| 日本无卡码免费一区二区三区| 久久久久久一品道精品免费看| 羞羞漫画在线成人漫画阅读免费| 亚洲精品福利网泷泽萝拉| 中文亚洲成a人片在线观看| 亚洲人成电影网站免费| 免费视频精品一区二区三区| 亚洲Aⅴ在线无码播放毛片一线天 亚洲avav天堂av在线网毛片 | 亚洲成在人线中文字幕| 国产精品亚洲mnbav网站| 成人免费视频一区二区三区| 久久精品国产这里是免费| 男性gay黄免费网站| 久久久国产亚洲精品| 亚洲人成网址在线观看| 国产精品亚洲mnbav网站| 国产性生交xxxxx免费| 无码日韩精品一区二区免费| 99视频在线看观免费| aa午夜免费剧场| 黄网站色成年片大免费高清| 亚洲中文无码亚洲人成影院|