Simple encryption and decryption algorithms
The simplest encryption and decryption method is simple string connection and computation, but it is troublesome to directly perform string operations, therefore, we recommend that you first convert the string to a byte array and then perform simple exclusive or operations or other operations to encrypt and decrypt the string and,
Void Start ()
{
String s = "sxasxasx time to that hour, an extra 2 ELE. Me 2221312312 ";
String SS = Encode (s );
Debug. Log (SS );
String SSS = Decode (SS );
Debug. Log (SSS );
Debug. Log (SSS = s );
}
Public string Encode (string s)
{
Byte [] B = Encoding. UTF8.GetBytes (s );
For (uint I = 0; I <B. Length; I ++)
{
Uint by = B [I];
B [I] = (byte) (by ^ 2); // you can use an exclusive or complex operation. Zero x 3234
}
Return Encoding. UTF8.GetString (B );
}
Public string Decode (string s)
{
Byte [] B = Encoding. UTF8.GetBytes (s );
For (uint I = 0; I <B. Length; I ++)
{
Uint by = B [I];
B [I] = (byte) (by ^ 2); // returns or
}
Return Encoding. UTF8.GetString (B );
}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.