public static string Encrypt(string strInput) { byte[] rgbKey = Encoding.ASCII.GetBytes("!@#$%^&*"); byte[] rgbIV = Encoding.ASCII.GetBytes("c_remote"); ICryptoTransform ICrypto = new DESCryptoServiceProvider().CreateEncryptor(rgbKey, rgbIV); byte[] inputByte = Encoding.UTF8.GetBytes(strInput); byte[] result = ICrypto.TransformFinalBlock(inputByte, 0, inputByte.Length); return Convert.ToBase64String(result, 0, result.Length); }
public static string Decrypt(string strInput) { byte[] rgbKey = Encoding.ASCII.GetBytes("!@#$%^&*"); byte[] rgbIV = Encoding.ASCII.GetBytes("c_remote"); ICryptoTransform desencrypt = new DESCryptoServiceProvider().CreateDecryptor(rgbKey, rgbIV); byte[] data = Convert.FromBase64String(strInput); byte[] result = desencrypt.TransformFinalBlock(data, 0, data.Length); return Encoding.UTF8.GetString(result); }
public static string Md5Encrypt(string sourceData) { string str3; Encoding encoding = new UTF8Encoding(); byte[] bytes = encoding.GetBytes("12345678"); byte[] rgbIV = new byte[] { 1, 2, 3, 4, 5, 6, 8, 7 }; string s = sourceData; try { ICryptoTransform transform = new DESCryptoServiceProvider().CreateEncryptor(bytes, rgbIV); byte[] inputBuffer = encoding.GetBytes(s); str3 = Convert.ToBase64String(transform.TransformFinalBlock(inputBuffer, 0, inputBuffer.Length)); } catch { throw; } return str3; }