The simplest code is given below, which adds additional functionality to the code, such as outputting the encrypted string to a file, reading the string to be encrypted or decrypted from the file ...
public class Encryption {//XOR/encryption algorithm public static void main (string[] args) {String password= "Happy Mid-Autumn Festival ... ";//to encrypt or decrypt the string Char[]array=password.tochararray ();//Gets the character array for (int i=0;i<array.length;i++)//Traversal character array {array[i]= ( Char) (Array[i] ^ 20140908);//For each array element, the XOR value can choose}system.out.println ("Encrypt or decrypt the result as follows:"); System.out.println (new String (array));//output encryption or decryption result}}
Results:
The results of encryption or decryption are as follows:
??? ᴼ according to the data
If
String password= "<span style=" FONT-SIZE:18PX; >???? According to According to </span> ";
Results:
The results of encryption or decryption are as follows:
Happy Mid-Autumn Festival ...
Java Small Knowledge point------The simplest encryption algorithm (XOR or encryption)