ASCII工具类
作者:互联网
对字符串简单的加密解密
描述:加密的时候对每个字符转成ASCII的时候进行 +1操作,最后用 “/” 拼接,解密原理相反。
/** * ASCII 工具类 * Created by Administrator on 2019/2/26. */ public class ASCIIUtils { /** * ASCII --> String * @param value * @return */ public static String asciiToString(String value) { StringBuffer sbu = new StringBuffer(); String[] chars = value.split("/"); for (int i = 0; i < chars.length; i++) { sbu.append((char) (Integer.parseInt(chars[i]) - 1)); } return sbu.toString(); } /** * 字符串转换为Ascii * @param value * @return */ public static String stringToAscii(String value) { StringBuffer sbu = new StringBuffer(); char[] chars = value.toCharArray(); for (int i = 0; i < chars.length; i++) { if (i != chars.length - 1) { sbu.append((int) chars[i]+1).append("/"); } else { sbu.append((int) chars[i]+1); } } return sbu.toString(); } }
标签:String,sbu,int,StringBuffer,chars,value,工具,ASCII 来源: https://www.cnblogs.com/Singulariity-gs/p/10442649.html