Java-簡單加密(亦或)
阿新 • • 發佈:2017-06-03
nextline 字符轉換 lin toc 16px 進行 accept col sta
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 }
Java-簡單加密(亦或)