10-31-2011، 03:16 PM
کد:
string SecureDataAlg(string StrInp,byte[] key,byte[] iv)
{
byte[] input = Encoding.UTF8.GetBytes(StrInp);
CryptoStream cryptoStream = null;
RijndaelManaged rijndael = null;
ICryptoTransform rijndaelTransform = null;
MemoryStream memStream = null;
rijndael = new RijndaelManaged();
rijndael.Key = key;
rijndael.IV = iv;
rijndaelTransform = rijndael.CreateEncryptor();
memStream = new MemoryStream();
cryptoStream = new CryptoStream(memStream, rijndaelTransform, CryptoStreamMode.Write);
cryptoStream.Write(input, 0, input.Length);
cryptoStream.FlushFinalBlock();
byte[] str = memStream.ToArray();
return Convert.ToBase64String(str);
}