用下面这种方式解密的数据,能不能得到它的加密方式?

        static string Password = "XXXXX";

        
public static string Decrypt(string source)
        {
            
string s;

            
if (String.IsNullOrEmpty(source))
                
throw new ArgumentException("No data given");
            
byte[] inputData = Convert.FromBase64String(source);
            
if (inputData.Length < 8)
                
throw new ArgumentException("Invalid input data");

            
byte[] salt = new byte[8];
            
for (int i = 0; i < salt.Length; i++)
            {
                salt[i] 
= inputData[i];
            }

            Rfc2898DeriveBytes rfc2898DeriveBytes 
= new Rfc2898DeriveBytes(Password, salt);
            Rijndael rijndael 
= Rijndael.Create();
            rijndael.Padding 
= PaddingMode.ISO10126;
            rijndael.IV 
= rfc2898DeriveBytes.GetBytes(rijndael.BlockSize / 8);
            rijndael.Key 
= rfc2898DeriveBytes.GetBytes(rijndael.KeySize / 8);
            
using (MemoryStream memoryStream = new MemoryStream())
            
using (
                CryptoStream cryptoStream 
=
                    
new CryptoStream(memoryStream, rijndael.CreateDecryptor(), CryptoStreamMode.Write))
            {
                cryptoStream.Write(inputData, 
8, inputData.Length - 8);
                cryptoStream.Close();
                
byte[] bytes = memoryStream.ToArray();
                s 
= Encoding.Unicode.GetString(bytes);
            }
            
return s;
        }
对加密解密这块不熟,请有经验的朋友解答,谢谢。
如果需要,我有几个样例数据与加密后的结果。

posted on 2007-05-06 00:01  deerchao  阅读(784)  评论(6编辑  收藏  举报