public void TestRobBase64Decryption() { var b64 = Base64.Encode("If this text is readable then the test has succeeded!"); var encoded = Xor.Cipher(b64, key); Assert.AreEqual("If this text is readable then the test has succeeded!", RobBase64.Decode(encoded, key), "No u"); }
public void TestXorDecryption() { const string original = "If this text is readable then the test has succeeded!"; var xor = Xor.Cipher(original, key); var cipher = Xor.Cipher(xor, key); Console.WriteLine(xor); Assert.AreEqual(original, cipher); }
public void TestDecryptGameSave() { var path = Path.Combine(GetFolderPath(SpecialFolder.LocalApplicationData), "GeometryDash"); var data = File.ReadAllText(path + Path.DirectorySeparatorChar + "CCLocalLevels.dat"); var xored = Xor.Cipher(data, 11); var replaced = xored.Replace('-', '+').Replace('_', '/').Replace("\0", string.Empty); var gzipb64 = GameManager.Decompress(Base64.DecodeToBytes(replaced)); Debug.WriteLine(Encoding.ASCII.GetString(gzipb64)); File.WriteAllBytes(Path.Combine(Directory.GetCurrentDirectory(), "test.xml"), gzipb64); }
/// <summary> /// A method to decompress the gamesave file to readable data for GDNET. /// </summary> /// <returns>Bytes, or readable data.</returns> public byte[] Decompress() { MemoryStream memory; byte[] data = Base64.DecodeToBytes(Xor.Cipher(File.ReadAllText(FilePath), 11) .Replace('-', '+').Replace('_', '/').Replace("\0", string.Empty)); using (GZipStream gZipStream = new GZipStream(new MemoryStream(data), CompressionMode.Decompress)) { byte[] buffer = new byte[4096]; int count; using (memory = new MemoryStream()) while ((count = gZipStream.Read(buffer, 0, 4096)) > 0) { memory.Write(buffer, 0, count); } return(InnerBytes = memory.ToArray()); } }
public static string Decode(string data, int key) => Base64.Decode(Xor.Cipher(data, key));