using System.Security.Cryptography;
public static void Main()
string username = "test";
string password = "1234";
string original = username + password;
original = original.PadLeft(32, '0').Substring(0, 32);
byte[] Key = Encoding.UTF8.GetBytes(original);
byte[] VI = new byte[16];
for(int i = 0; i < 16; i++)
VI[i] = Key[Key.Length - 1 - i];
using (Aes myAes = Aes.Create())
byte[] encrypted = EncryptStringToBytes_Aes(original, Key, VI);
Console.WriteLine("byte[] encrypted = new byte[] { " + string.Join(",", encrypted) + " };");
static byte[] EncryptStringToBytes_Aes(string plainText, byte[] Key, byte[] IV)
using (Aes aesAlg = Aes.Create())
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
using (MemoryStream msEncrypt = new MemoryStream())
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
swEncrypt.Write(plainText);
encrypted = msEncrypt.ToArray();