1. 程式人生 > >利用位運算簡單實現加密運算

利用位運算簡單實現加密運算

enter pre nextline span stat scan cnblogs system.in str

 1  public static void main(String[] args){
 2        Scanner scanner = new Scanner(System.in);
 3        System.out.println("please enter something:");
 4        String str = scanner.nextLine();
 5        char[] array = str.toCharArray(); //獲取字符數組
 6         for (int i = 0; i<array.length;i++){
 7
array[i] = (char)(array[i]^2000); 8 } 9 System.out.println("加密結果:"+ new String(array)); 10 }

利用位運算簡單實現加密運算