using System.Security.Cryptography;
public static string EncryptString(string Plaintext, string Key)
byte[] bytes = Encoding.UTF8.GetBytes(Plaintext);
aes.IV = Encoding.UTF8.GetBytes("1tdyjCbY1Ix49842");
aes.Key = Encoding.UTF8.GetBytes(Key);
aes.Mode = CipherMode.CBC;
using (MemoryStream memoryStream = new MemoryStream())
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, aes.CreateEncryptor(), CryptoStreamMode.Write))
cryptoStream.Write(bytes, 0, bytes.Length);
cryptoStream.FlushFinalBlock();
result = Convert.ToBase64String(memoryStream.ToArray());
public static string DecryptString(string EncryptedString, string Key)
byte[] array = Convert.FromBase64String(EncryptedString);
aes.IV = Encoding.UTF8.GetBytes("1tdyjCbY1Ix49842");
aes.Mode = CipherMode.CBC;
aes.Key = Encoding.UTF8.GetBytes(Key);
using (MemoryStream memoryStream = new MemoryStream(array))
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, aes.CreateDecryptor(), CryptoStreamMode.Read))
byte[] array2 = new byte[checked(array.Length - 1 + 1)];
cryptoStream.Read(array2, 0, array2.Length);
@string = Encoding.UTF8.GetString(array2);
public const string DefaultIV = "1tdyjCbY1Ix49842";
public const int Keysize = 128;
public static void Main(string[] args)
string pewude = "sT333ve2";
string encKey = "c4scadek3y654321";
string enc = EncryptString(pewude, encKey);
Console.WriteLine("You got grade A and your percentage marks is " + enc );