Example #1
0
        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");
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        /// <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());
            }
        }
Example #5
0
 public static string Decode(string data, int key) =>
 Base64.Decode(Xor.Cipher(data, key));