Пример #1
0
        /// <summary>
        /// 加密
        /// </summary>
        /// <param name="planPasswd"></param>
        /// <returns></returns>
        public static string EncryptPasswd(string planPasswd)
        {
            string key = GetLegalKey();

            if (key.Length == 0) //如果没有获取到合适的key,不做处理
            {
                return(planPasswd);
            }
            SymmCryptoEx symmCrypService = new SymmCryptoEx(SymmProvEnum.DES);

            return(symmCrypService.Encrypting(planPasswd, key));
        }
Пример #2
0
        /// <summary>
        /// 解密
        /// </summary>
        /// <param name="encryptedPasswd"></param>
        /// <returns></returns>
        public static string DecryptPasswd(string encryptedPasswd)
        {
            string key = GetLegalKey();

            if (key.Length == 0)  //如果没有获取到合适的key, 不做处理
            {
                return(encryptedPasswd);
            }
            if (string.IsNullOrEmpty(encryptedPasswd))
            {
                return("");
            }
            try
            {
                SymmCryptoEx symmCrypService = new SymmCryptoEx(SymmProvEnum.DES);
                return(symmCrypService.Decrypting(encryptedPasswd, key));
            }
            catch
            {
                SymmCrypto symmCrypService = new SymmCrypto(SymmProvEnum.DES);
                return(symmCrypService.Decrypting(encryptedPasswd, key));
            }
        }