Example #1
0
        public static byte[] ReadAllBytes(string path, bool decrypt = true)
        {
            if (!File.Exists(path))
            {
                Debug.LogError("File \"" + path + "\" doesn't exist");
                return(null);
            }

            if (!decrypt)
            {
                return(File.ReadAllBytes(path));
            }

            byte[] bytes = File.ReadAllBytes(path);
            if (bytes.Length == 0)
            {
                return(bytes);
            }

            string line = MCrypt.DecryptByteArray(bytes);

            bytes = MUtil.StringToByteArray(line);

            return(bytes);
        }
Example #2
0
        public static void WriteAllBytes(string path, byte[] content, bool encrypt = true)
        {
            if (!encrypt)
            {
                File.WriteAllBytes(path, content);
                return;
            }

            string line = MUtil.ByteArrayToString(content);

            content = MCrypt.EncryptString(line);

            File.WriteAllBytes(path, content);
        }
Example #3
0
        public static string[] ReadAllLines(string path, bool decrypt = true)
        {
            if (!decrypt)
            {
                return(File.ReadAllLines(path));
            }

            /*string content = File.ReadAllText(path);
             *
             * byte[] contentByte = MUtil.StringToByteArray(content);*/

            byte[] contentByte = File.ReadAllBytes(path);
            if (contentByte.Length == 0)
            {
                return(new string[0]);
            }

            string content = MCrypt.DecryptByteArray(contentByte);

            return(MUtil.StringToStringArray(content));
        }