コード例 #1
0
        /// <summary>
        /// 加密方法
        /// </summary>
        /// <param name="str">加密字符串</param>
        /// <param name="code">加密长度,只有MD5加密有本参数</param>
        /// <param name="type">产生密码类型</param>
        /// <param name="type">密钥</param>
        /// <returns></returns>
        public static string EncryptString(string str, int code, EncryptorType type, string passKey)
        {
            string _tempString = str;

            switch (type)
            {
            case EncryptorType.DES:
                _tempString = new DESEncryptor().EncryptString(str);
                break;

            case EncryptorType.DES3:
                break;

            case EncryptorType.MD5:
                _tempString = MD5Encryptor.MD5(str, code);
                break;

            case EncryptorType.Base64:
                _tempString = new Base64Encryptor().EncryptString(str);
                break;

            case EncryptorType.SHA256:
                _tempString = SHA256Encryptor.SHA256(str);
                break;

            case EncryptorType.DESByEncryptKey:
                _tempString = DESByEncryptKey.EncryptDES(str, passKey);
                break;

            default:
                throw new ArgumentException("无效的加密类型");
            }
            return(_tempString);
        }
コード例 #2
0
 public IVEncryptorInfo(string innerLibName, int keySize, int ivSize, EncryptorType type)
 {
     KeySize      = keySize;
     IVSize       = ivSize;
     Type         = type;
     InnerLibName = innerLibName;
 }
コード例 #3
0
        /// <summary>
        /// 解密方法
        /// </summary>
        /// <param name="str">需解密字符</param>
        /// <param name="type">解密方法</param>
        /// <returns></returns>
        public static string DecryptString(string str, EncryptorType type, string passKey)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                return(str);
            }

            string _tempString = str;

            switch (type)
            {
            case EncryptorType.DES:
                _tempString = new DESEncryptor().DecryptString(str);
                break;

            case EncryptorType.DES3:
                break;

            case EncryptorType.Base64:
                _tempString = new Base64Encryptor().DecryptString(str);
                break;

            case EncryptorType.DESByEncryptKey:
                _tempString = DESByEncryptKey.DecryptDES(str, passKey);
                break;

            default:
                throw new ArgumentException("无效的加密类型");
            }

            return(_tempString);
        }
コード例 #4
0
        /// <summary>
        /// 解密方法
        /// </summary>
        /// <param name="str">需解密字符</param>
        /// <param name="type">解密方法</param>
        /// <returns></returns>
        public static string DecryptString(string str, EncryptorType type)
        {
            if (string.IsNullOrWhiteSpace(str))
            {
                return(str);
            }

            string _tempString = str;

            switch (type)
            {
            case EncryptorType.DES:
                throw new ArgumentException("无效的加密类型");

            default:
                throw new ArgumentException("无效的加密类型");
            }
        }
コード例 #5
0
        /// <summary>
        /// 加密方法
        /// </summary>
        /// <param name="str">加密字符串</param>
        /// <param name="code">加密长度,只有MD5加密有本参数</param>
        /// <param name="type">产生密码类型</param>
        /// <param name="type">密钥</param>
        /// <returns></returns>
        public static string EncryptString(string str, EncryptorType type)
        {
            string _tempString = str;

            switch (type)
            {
            case EncryptorType.DES:
                throw new ArgumentException("没有实现");

            case EncryptorType.MD5:
                _tempString = MD5Encryptor.MD5(str);
                break;

            default:
                throw new ArgumentException("无效的加密类型");
            }
            return(_tempString);
        }
コード例 #6
0
 public static string DecryptString(string str, EncryptorType type)
 {
     return(DecryptString(str, type, null));
 }
コード例 #7
0
 /// <summary>
 /// 加密方法(32位)
 /// </summary>
 /// <param name="str">加密字符串</param>
 /// <param name="type">产生密码类型</param>
 /// <returns></returns>
 public static string EncryptString(string str, EncryptorType type)
 {
     return(EncryptString(str, 32, type, null));
 }
コード例 #8
0
 public static bool Verify(string input, string hash, EncryptorType encryptorType, string salt)
 {
     EncryptorBase enc = Init(encryptorType.ToString());
     return enc.Verify(input, hash, salt);
 }
コード例 #9
0
 public static string Encrypt(string input, EncryptorType encryptorType, string salt)
 {
     EncryptorBase enc = Init(encryptorType.ToString());
     return enc.Encrypt(input, salt);
 }
コード例 #10
0
 public static string Decrypt(string input, EncryptorType encryptorType)
 {
     EncryptorBase enc = Init(encryptorType.ToString());
     return enc.Decrypt(input);
 }
コード例 #11
0
        public static string Encrypt(string input, EncryptorType encryptorType)
        {
            EncryptorBase enc = Init(encryptorType.ToString());

            return(enc.Encrypt(input));
        }
コード例 #12
0
        public static bool Verify(string input, string hash, EncryptorType encryptorType, string salt)
        {
            EncryptorBase enc = Init(encryptorType.ToString());

            return(enc.Verify(input, hash, salt));
        }
コード例 #13
0
        public static string Decrypt(string input, EncryptorType encryptorType, string salt)
        {
            EncryptorBase enc = Init(encryptorType.ToString());

            return(enc.Decrypt(input, salt));
        }
コード例 #14
0
 public IVEncryptorInfo(int keySize, int ivSize, EncryptorType type)
     : this("", keySize, ivSize, type)
 {
 }