对文字简单的加密解密

 1 /**
 2      * 测试byte 
 3      */
 4     public void test3(){
 5         String str = "菲吓鳞";
 6         byte[] b = new byte[1024];
 7         b = str.getBytes();
 8         byte[] fs = new byte[1024];
 9         for (int i = 0; i < b.length; i++) {
10             byte f =  b[i];
11             if(f == 255){
12                 f = 0;
13             }else{
14                 fs[i] += --f;
15             }
16         }
17         System.out.println("加密后:" + new String(fs));
18         
19         byte[] yb = new byte[1024];
20         for (int i = 0; i < fs.length; i++) {
21             byte f = fs[i];
22             if(f == 0){
23                 f=(byte) 255;
24             }else{
25                 yb[i] += ++f;
26             }
27         }
28         System.out.println("解密后:" + new String(yb));
29     }

 

posted @ 2014-03-25 14:37  哎呦喂,我的小祖宗╰つ  阅读(482)  评论(0编辑  收藏  举报