internal SymmetricAlgorithm GetProvider(Encryption.CryptoProvider provider) { switch (provider) { case Encryption.CryptoProvider.DES: return(new DESCryptoServiceProvider()); case Encryption.CryptoProvider.RC2: return(new RC2CryptoServiceProvider()); case Encryption.CryptoProvider.TripleDES: return(new TripleDESCryptoServiceProvider()); default: return(null); } }
public string Encryption(string sStr) { var uTF = Encoding.UTF8; Encryption.CryptoProvider defaultProvider = ColtSmart.Encrypt.Encryption.CryptoProvider.TripleDES; var encryption = new Encryption(this.sKey, defaultProvider); string text = encryption.Encrypt(sStr); byte[] bytes = uTF.GetBytes(text); text = ""; byte[] array = bytes; for (int i = 0; i < array.Length; i++) { byte b = array[i]; string text2 = string.Format("{0:X2}", b); text += text2; } return(text); }
public string Decryption(string sStr) { int i = 0; Encoding uTF = Encoding.UTF8; byte[] array = new byte[sStr.Length / 2]; char[] array2 = sStr.ToCharArray(); while (i < sStr.Length) { array[i / 2] = Convert.ToByte(Uri.FromHex(array2[i]) * 16 + Uri.FromHex(array2[i + 1])); i += 2; } char[] array3 = new char[uTF.GetCharCount(array, 0, array.Length)]; uTF.GetChars(array, 0, array.Length, array3, 0); string encryptedString = new string(array3); Encryption.CryptoProvider defaultProvider = ColtSmart.Encrypt.Encryption.CryptoProvider.TripleDES; var encryption = new Encryption(this.sKey, defaultProvider); return(encryption.Decrypt(encryptedString)); }
public Encryption(string defaultKey, Encryption.CryptoProvider defaultProvider) : this(defaultKey) { this.provider = defaultProvider; }
public Encryption(Encryption.CryptoProvider defaultProvider) : this() { this.provider = defaultProvider; }