本文整理汇总了C#中System.Security.Cryptography.DESCryptoServiceProvider.TransformFinalBlock方法的典型用法代码示例。如果您正苦于以下问题:C# DESCryptoServiceProvider.TransformFinalBlock方法的具体用法?C# DESCryptoServiceProvider.TransformFinalBlock怎么用?C# DESCryptoServiceProvider.TransformFinalBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.DESCryptoServiceProvider
的用法示例。
在下文中一共展示了DESCryptoServiceProvider.TransformFinalBlock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Encrypt
public static string Encrypt(string strInput)
{
byte[] rgbKey = Encoding.ASCII.GetBytes("[email protected]#$%^&*");
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);
}
示例2: Decrypt
public static string Decrypt(string strInput)
{
byte[] rgbKey = Encoding.ASCII.GetBytes("[email protected]#$%^&*");
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);
}
示例3: Md5Encrypt
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;
}