Exemple #1
0
        /// <summary>
        /// 解密文件
        /// </summary>
        /// <param name="filePath">输入文件路径</param>
        /// <param name="savePath">解密后输出文件路径</param>
        /// <param name="keyStr">密码,可以为“”</param>
        /// <returns></returns>
        public static bool DecryptFile(string filePath, string savePath, string keyStr)
        {
            if (string.IsNullOrEmpty(keyStr))
            {
                throw new Exception("加密密钥不能为空");
            }

            DesCryptoService des = new DesCryptoService(keyStr, DESCryptoServiceProvider.Create());

            return(des.DecryptFile(filePath, savePath));
        }
Exemple #2
0
        /// <summary>
        /// 解密字符串
        /// </summary>
        /// <param name="inputStr">要解密的字符串</param>
        /// <param name="keyStr">密钥</param>
        /// <returns>解密后的结果</returns>
        static public string SDecryptString(string inputStr, string keyStr)
        {
            if (string.IsNullOrEmpty(keyStr))
            {
                throw new Exception("加密密钥不能为空");
            }

            DesCryptoService des = new DesCryptoService(keyStr, DESCryptoServiceProvider.Create());

            return(des.DecryptString(inputStr));
        }