加密解密时可以用到,只支持小写字母的转换。
加密解密时可以用到,只支持小写字母的转换。
private String dmix(String str1)
{
int MAX_COUNT = 20;
char ca[] = str1.toCharArray();
int count = 0;
for(int i = 0; i < ca.length; i++)
{
int a = ca[i] - count;
ca[i] = (char)a;
if(ca[i] < 'a')
ca[i] += '\032';
count = ++count % MAX_COUNT;
}
StringBuffer sb = new StringBuffer();
sb.append(ca);
return sb.toString();
}
public String mix(String str1)
{
int MAX_COUNT = 20;
char ca[] = str1.toCharArray();
int count = 0;
for(int i = 0; i < ca.length; i++)
{
int a=0;
a = ca[i] + count;
ca[i] = (char)a;
if(ca[i] > 'z')
ca[i] -= '\032';
count = ++count % MAX_COUNT;
}
StringBuffer sb = new StringBuffer();
sb.append(ca);
return sb.toString();
}
网友评论