//Copyright (c) AceInfinity - Tech.Reboot.Pro
//String bit encoding example
string originalObj = "Let's have ourselves a Fiesta!!!";
Console.WriteLine("Original: {0}", originalObj);
Console.WriteLine("-------------------");
// Encoding
originalObj += "\0";
char* objEncode = stackalloc char[originalObj.Length];
for (int i = 0; i < originalObj.Length; i++)
{
int j = (int)originalObj ^ (i + 1);
objEncode = (char)j;
}
string encodedObj = new string(objEncode);
Console.WriteLine("Encoded: {0}", encodedObj);
// Decoding
char* objDecode = stackalloc char[encodedObj.Length];
for (int i = 0; i < encodedObj.Length; i++)
{
int j = (int)encodedObj ^ (i + 1);
objDecode = (char)j;
}
string decodedObj = new string(objDecode);
Console.WriteLine("Decoded: {0}", decodedObj);