标签:字节数组 加密 rar lse builder put 反转 NPU 密文
凯撒加密:
public static void main(String[] args) { String input="hello world"; //向右移动 int key =3; //转换字节数组 char[] chars=input.toCharArray(); //装密文 StringBuilder sb = new StringBuilder(); for (char c :chars ) { int d=c; d = d+key; char newd= (char) d; sb.append(newd); } System.out.println("密文:"+sb.toString()); //反转 StringBuilder bs = new StringBuilder(); String output =sb.toString(); char[] outchars=output.toCharArray(); for (char c : outchars) { int d=c; d= d-key; char newd= (char) d; bs.append(newd); } System.out.println("明文:" + bs.toString()); }
标签:字节数组 加密 rar lse builder put 反转 NPU 密文
原文地址:https://www.cnblogs.com/money131/p/13192843.html