/// <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); }
public IVEncryptorInfo(string innerLibName, int keySize, int ivSize, EncryptorType type) { KeySize = keySize; IVSize = ivSize; Type = type; InnerLibName = innerLibName; }
/// <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); }
/// <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("无效的加密类型"); } }
/// <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); }
public static string DecryptString(string str, EncryptorType type) { return(DecryptString(str, type, null)); }
/// <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)); }
public static bool Verify(string input, string hash, EncryptorType encryptorType, string salt) { EncryptorBase enc = Init(encryptorType.ToString()); return enc.Verify(input, hash, salt); }
public static string Encrypt(string input, EncryptorType encryptorType, string salt) { EncryptorBase enc = Init(encryptorType.ToString()); return enc.Encrypt(input, salt); }
public static string Decrypt(string input, EncryptorType encryptorType) { EncryptorBase enc = Init(encryptorType.ToString()); return enc.Decrypt(input); }
public static string Encrypt(string input, EncryptorType encryptorType) { EncryptorBase enc = Init(encryptorType.ToString()); return(enc.Encrypt(input)); }
public static bool Verify(string input, string hash, EncryptorType encryptorType, string salt) { EncryptorBase enc = Init(encryptorType.ToString()); return(enc.Verify(input, hash, salt)); }
public static string Decrypt(string input, EncryptorType encryptorType, string salt) { EncryptorBase enc = Init(encryptorType.ToString()); return(enc.Decrypt(input, salt)); }
public IVEncryptorInfo(int keySize, int ivSize, EncryptorType type) : this("", keySize, ivSize, type) { }