well-known as crypter or stub
public static string Encrypt(string textToEncrypt, string key)
{
RijndaelManaged RijndaelCipher = new RijndaelManaged();
byte[] PlainText = Encoding.Unicode.GetBytes(textToEncrypt);
byte[] Salt = Encoding.ASCII.GetBytes(key.Length.ToString());
PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(key, Salt);
ICryptoTransform Encryptor = RijndaelCipher.CreateEncryptor(SecretKey.GetBytes(32), SecretKey.GetBytes(16));
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, Encryptor, CryptoStreamMode.Write);
cryptoStream.Write(PlainText, 0, PlainText.Length);
cryptoStream.FlushFinalBlock();
byte[] CipherBytes = memoryStream.ToArray();
memoryStream.Close();
cryptoStream.Close();
return Convert.ToBase64String(CipherBytes);
}
For educational