Java-简单加密(亦或)
1 import java.net.PasswordAuthentication; 2 import java.util.Scanner; 3 4 public class Encryption { 5 public static void main(String[] args) { 6 System.out.println("enter a character or an encurpted character"); 7 Scanner input=new Scanner(System.in); 8 String accept=input.nextLine();//获取用户输入字符 9 char []array=accept.toCharArray();//获取字符转换为字符数组 10 for(int i=0;i<array.length;i++){ 11 array[i]=(char)(array[i]^20000);//进行亦或处理 12 } 13 System.out.println("Encrypt or decrypt of the results are as follows"); 14 System.out.println(new String(array));//输出密匙 15 } 16 }