|
public string Decrypt(string pToDecrypt, string sKey)
{
DESCryptoServiceProvider provider1 = new DESCryptoServiceProvider();
byte[] buffer1 = new byte[pToDecrypt.Length / 2];
for (int num1 = 0; num1 < (pToDecrypt.Length / 2); num1++)
{
int num2 = Convert.ToInt32(pToDecrypt.Substring(num1 * 2, 2), 0x10);
buffer1[num1] = (byte) num2;
}
provider1.Key = Encoding.ASCII.GetBytes(sKey);
provider1.IV = Encoding.ASCII.GetBytes(sKey);
MemoryStream stream1 = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream1, provider1.CreateDecryptor(), CryptoStreamMode.Write);
stream2.Write(buffer1, 0, buffer1.Length);
stream2.FlushFinalBlock();
StringBuilder builder1 = new StringBuilder();
return Encoding.Default.GetString(stream1.ToArray());
}
==============================================
以上是解密的方法。
调用是这样的:this.Decrypt("48FC50F3F5EB1A4B9CF9FA16765A4812", "2%b<5X7*");
"48FC50F3F5EB1A4B9CF9FA16765A4812" 是"127.0.0.1"加密后的字符
"2%b<5X7*" 是KEY
我想问的是这个:"48FC50F3F5EB1A4B9CF9FA16765A4812"
是通过加密过来的。他的长度是32位。我不知道是怎么加密过来的!
谁能告诉我怎么样才能达到这样的效果?
我自己写了一个加密
public string Encryptor(string pToEncryptor, string sKey)
{
DESCryptoServiceProvider provider1 = new DESCryptoServiceProvider();
byte[] buffer1 = ASCIIEncoding.Default.GetBytes(pToEncryptor);
provider1.Key = Encoding.ASCII.GetBytes(sKey);
provider1.IV = Encoding.ASCII.GetBytes(sKey);
MemoryStream stream1 = new MemoryStream();
CryptoStream stream2 = new CryptoStream(stream1, provider1.CreateEncryptor(), CryptoStreamMode.Write);
stream2.Write(buffer1, 0, buffer1.Length);
stream2.FlushFinalBlock();
StringBuilder builder1 = new StringBuilder();
return Encoding.Default.GetString(stream1.ToArray());
}
但是出来的String 是一堆不知道是什么的String |
|