|
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 ());
}
==================================================
The above is the method of decryption.
The call is this: This.Decrypt ("48FC50F3F5EB1A4B9CF9FA16765A4812", "2% b <5X7 *");
"48FC50F3F5EB1A4B9CF9FA16765A4812" is the encrypted character of "127.0.0.1"
"2% b <5X7 *" is KEY
What I want to ask is this: "48FC50F3F5EB1A4B9CF9FA16765A4812"
It came through encryption. His length is 32 bits. I don't know how it was encrypted!
Can anyone tell me how I can achieve this effect?
I wrote an encryption myself
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 ());
}
But the String that comes out is a bunch of Strings that don't know what |
|