Exemple #1
0
        /// <summary>
        /// 整体加密文件
        /// </summary>
        /// <param name="sourceFile">待加密的文件名</param>
        /// <param name="targetFile">保存加密文件名</param>
        /// <param name="key">密钥字符串,长度为8或者24</param>
        public static void EncryptFile(string sourceFile, string targetFile, string key)
        {
            sourceFile.CheckFileExists("sourceFile");
            targetFile.CheckNotNullOrEmpty("targetFile");
            key.CheckNotNullOrEmpty("key");

            byte[]    keyBytes = Encoding.UTF8.GetBytes(key);
            DesHelper des      = new DesHelper(keyBytes);

            des.EncryptFile(sourceFile, targetFile);
        }
Exemple #2
0
        /// <summary>
        /// 分段加密文件
        /// </summary>
        /// <param name="sourceFile">待加密的文件名</param>
        /// <param name="targetFile">保存加密文件名</param>
        /// <param name="sectionLength">分段大小(字节)</param>
        /// <param name="key">密钥字符串,长度为8或者24</param>
        public static void EncryptFile(string sourceFile, string targetFile, int sectionLength, string key)
        {
            sourceFile.CheckFileExists("sourceFile");
            targetFile.CheckNotNullOrEmpty("targetFile");
            key.CheckNotNullOrEmpty("key");
            sectionLength.CheckGreaterThan("sectionLength", 0);

            byte[]    keyBytes = Encoding.UTF8.GetBytes(key);
            DesHelper des      = new DesHelper(keyBytes);

            des.EncryptFile(sourceFile, targetFile, sectionLength);
        }
Exemple #3
0
        /// <summary>
        /// 分段加密文件
        /// </summary>
        /// <param name="sourceFile">待加密的文件名</param>
        /// <param name="targetFile">保存加密文件名</param>
        /// <param name="sectionLength">分段大小(字节)</param>
        /// <param name="key">密钥字符串,长度为8或者24</param>
        public static void EncryptFile(string sourceFile, string targetFile, int sectionLength, string key)
        {
            sourceFile.CheckFileExists("sourceFile");
            targetFile.CheckNotNullOrEmpty("targetFile");
            key.CheckNotNullOrEmpty("key");
            sectionLength.CheckGreaterThan("sectionLength", 0);

            byte[] keyBytes = Encoding.UTF8.GetBytes(key);
            DesHelper des = new DesHelper(keyBytes);
            des.EncryptFile(sourceFile, targetFile, sectionLength);
        }
Exemple #4
0
        /// <summary>
        /// 整体加密文件
        /// </summary>
        /// <param name="sourceFile">待加密的文件名</param>
        /// <param name="targetFile">保存加密文件名</param>
        /// <param name="key">密钥字符串,长度为8或者24</param>
        public static void EncryptFile(string sourceFile, string targetFile, string key)
        {
            sourceFile.CheckFileExists("sourceFile");
            targetFile.CheckNotNullOrEmpty("targetFile");
            key.CheckNotNullOrEmpty("key");

            byte[] keyBytes = Encoding.UTF8.GetBytes(key);
            DesHelper des = new DesHelper(keyBytes);
            des.EncryptFile(sourceFile, targetFile);
        }