A few days ago, I searched for an article about Java bit operations. I saw a program on a blog, which roughly refers to the displacement of strings. Then I said that adding some other operations is an encryption program. Ah ...... I don't know if he has tried it. I think I know that after the data is displaced, the data that is removed will be discarded. Instead, it is replaced by zero or one, only Cyclic Displacement can achieve the effect of moving to and from without data loss, while >>,<<does not carry loops. I tested it myself and found it interesting that the GBK encoding in Chinese seems to be recorded in pinyin, but I have not studied it either, it's just a conjecture from the program.
// Bit operation
Import java. Io .*;
Class javabit ...{
Public static void main (string [] ARGs) throws java. Io. unsupportedencodingexception, ioexception ...{
Bufferedreader bufr = new bufferedreader (New inputstreamreader (system. In ));
System. Out. println ("Enter the string :");
String STR = bufr. Readline ();
Byte [] bitarray = Str. getbytes ();
System. Out. println ("the input string is:" + new string (bitarray, "GBK "));
Int I = 0;
For (; I <bitarray. length; I ++ )...{
Bitarray [I] = (byte) (bitarray [I]> 1 );
}
System. Out. println ("shifted string:" + new string (bitarray, "GBK "));
For (I = 0; I <bitarray. length; I ++ )...{
Bitarray [I] = (byte) (bitarray [I] <1 );
}
System. Out. println ("the returned string is:" + new string (bitarray, "GBK "));
System. Out. println ("String Length:" + I );
System. Out. println (I + "binary representation:" + integer. tobinarystring (I ));
I = I <3;
System. Out. println ("the value after the shift is:" + I );
System. Out. println (I + "binary representation:" + integer. tobinarystring (I ));
}
}
I entered: You are pig 3. After the displacement, the result is: too many characters, too many characters. Of course, other words cannot be connected. Then I moved them back (loss of precision ), that is to say, a 0 is added later, and the result is: It's interesting to plan a Zhu tan competition. Of course, people who know the encoding sequence will not find it interesting.