public static void LoadStrings()
        {
            byte[] stringByteArray;

            // Stores the current executing assembly and stores it in a variable.
            Assembly currentAssembly = Assembly.GetExecutingAssembly();

            // TODO: Encrypt the string here as it is skipped.
            string stringResourceName = currentAssembly.GetManifestResourceNames()
                                        .Aggregate("", (current, s) => (s == ByteGuardHelper.GetMd5(current) ? s : current));

            // Creates a stream using the embedded resource in the current assembly.
            using (Stream resourceStream = currentAssembly.GetManifestResourceStream(stringResourceName))//BYTEGUARDRESOURCESTRINGPADDINGBYTEGUARD"))
            {
                // Resizes the 'StringByteArray' to the correct size.
                stringByteArray = new byte[resourceStream.Length];

                // Reads the bytes from the embedded resource into the 'StringByteArray'.
                resourceStream.Read(stringByteArray, 0, stringByteArray.Length);
            }

            // Decompresses the compressed bytes.
            //if (DecompressEmbeddedStrings())
            stringByteArray = ByteGuardHelper.GzipDecompressBytes(stringByteArray);

            stringByteArray = AesDecrypt(stringByteArray, (stringResourceName + ByteGuardHelper.GetMd5(K)));

            B = stringByteArray;
        }
        // TODO: Encrypt offline strings.
        // TODO: Use MD5 hash of all offline strings to protect online strings?
        public static void LoadStringsOffline()
        {
            byte[] stringByteArray;

            // Get the currently executing assembly and stores it in a variable.
            Assembly currentAssembly = Assembly.GetExecutingAssembly();

            string stringResourceName = currentAssembly.GetManifestResourceNames()
                                        .Aggregate("", (current, s) => (s == ByteGuardHelper.GetMd5(current) ? s : current));

            using (Stream resourceStream = currentAssembly.GetManifestResourceStream(stringResourceName))
            {
                // Resizes the 'stringByteArray' to the correct size.
                stringByteArray = new byte[resourceStream.Length];

                // Reads the bytes from the embdded resource into the 'stringByteArray'.
                resourceStream.Read(stringByteArray, 0, stringByteArray.Length);
            }

            stringByteArray = ByteGuardHelper.GzipDecompressBytes(stringByteArray);

            O = stringByteArray;
        }
예제 #3
0
        public static void LoadIntegers()
        {
            // Stores the current executing assembly and stores it in a variable.
            Assembly currentAssembly = Assembly.GetExecutingAssembly();

            string resourceName = currentAssembly.GetManifestResourceNames()
                                  .Aggregate("", (current, s) => (s == ByteGuardHelper.GetMd5(current) ? s : current));

            // Creates a stream using the embedded resource in the current assembly.
            using (Stream resourceStream = currentAssembly.GetManifestResourceStream(resourceName))
            {
                // Resizes the 'StringByteArray' to the correct size.
                B = new byte[resourceStream.Length];

                // Reads the bytes from the embedded resource into the 'StringByteArray'.
                resourceStream.Read(B, 0, B.Length);
            }

            B = ByteGuardStringProtections.AesDecrypt(
                ByteGuardHelper.GzipDecompressBytes(B), (resourceName + ByteGuardHelper.GetMd5(K)));

            //B = ByteGuardStringProtections.AesDecrypt(B, key);
        }