1. 程式人生 > >ASCII碼字符串普通加密解密-android

ASCII碼字符串普通加密解密-android

i++ color scl arr ++ array 後臺 uil new

                  
            //android後臺Java
             //ASCII加密
String str = e.getText().toString();
StringBuilder s = new StringBuilder();
char[] c = str.toCharArray();
for (int i = 0; i < str.length(); i++) {
int a = c[i];
a = a + 7;
s.append((char) a) ;
}

//ascll解密一
// String d = "";
// char[] c2 = s.toString().toCharArray();
// for (int i = 0; i < s.length(); i++) {
// int b = c2[i];

// b = b - 7;
// d = d + (char) b;
// }
//ascll解密二
StringBuilder d = new StringBuilder();
char[] c2 = s.toString().toCharArray();
for (int i = 0; i < s.length(); i++) {
int b = c2[i];
b = b - 7;
d.append((char) b);
}

ASCII碼字符串普通加密解密-android