⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binarydecryptor.cs

📁 这是可以加密&解密字符串
💻 CS
字号:
using System.Security.Cryptography;
using System.IO;

namespace GTT
{
    public class BinaryDecryptor : BinaryCrypto
    {
        /// <remarks>
        /// 使用.Net SymmetricAlgorithm 类的构造器.
        /// </remarks>
        public BinaryDecryptor(SymmProvEnum netSelected)
            : base(netSelected)
        {
        }
        /// <remarks>
        /// 使用自定义SymmetricAlgorithm类的构造器.
        /// </remarks>
        public BinaryDecryptor(SymmetricAlgorithm ServiceProvider)
            : base(ServiceProvider)
        {
        }

        public override byte[] ExecuteBytes(byte[] inputBytes)
        {
            // create a MemoryStream with the input
            System.IO.MemoryStream ms = new System.IO.MemoryStream(inputBytes, 0, inputBytes.Length);
            byte[] bytKey = GetLegalKey(Key);
            // set the private key
            _mobjCryptoService.Key = bytKey;
            _mobjCryptoService.IV = bytKey;
            // create a Decryptor from the Provider Service instance
            ICryptoTransform encrypto = _mobjCryptoService.CreateDecryptor();
            // create Crypto Stream that transforms a stream using the decryption
            CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write);
            // read out the result from the Crypto Stream
            cs.Write(inputBytes, 0, inputBytes.Length);
            cs.Flush();
            return ms.ToArray();
        }

        public override void ExecuteStream(Stream inputStream, Stream outputStream)
        {
            byte[] buffer = new byte[1032];
            byte[] buf = new byte[1024];
            int temp;
            do
            {
                temp = inputStream.Read(buffer, 0, 1032);
                buf = ExecuteBytes(buffer);
                if (temp > 0)
                {
                    outputStream.Write(buf, 0, temp - 8);
                }
                else
                    break;
            }
            while (true);
        }

        public override bool ExecuteFile(string inputfile, string outputfile)
        {
            if (System.IO.File.Exists(inputfile))
            {
                Stream inStream = File.Open(inputfile, FileMode.Open);
                Stream outStream = File.Create(outputfile);
                ExecuteStream(inStream, outStream);
                inStream.Close();
                outStream.Close();
            }
            return true;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -