using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
public class Test
{
public static void Main()
{
byte[] key = new byte[]
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
};
byte[] iv = new byte[]
{
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
};
byte[] clearData = Encoding.UTF8.GetBytes("Hello world! This is a wonderful day! àèéìòù");
using (Rijndael alg = Rijndael.Create())
{
alg.Key = key;
alg.IV = iv;
using (var ms = new MemoryStream())
{
CryptoStream cs = new CryptoStream(ms, alg.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(clearData, 0, clearData.Length);
cs.Close();
byte[] encryptedData = ms.ToArray();
Console.WriteLine(BitConverter.ToString(encryptedData).Replace("-", "").ToLowerInvariant());
}
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uSU87CnVzaW5nIFN5c3RlbS5TZWN1cml0eS5DcnlwdG9ncmFwaHk7CnVzaW5nIFN5c3RlbS5UZXh0OwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewogICAgICAgIGJ5dGVbXSBrZXkgPSBuZXcgYnl0ZVtdIAogICAgICAgIHsgCiAgICAgICAgICAgIDB4MDAsIDB4MDEsIDB4MDIsIDB4MDMsIDB4MDQsIDB4MDUsIDB4MDYsIDB4MDcsCiAgICAgICAgICAgIDB4MDgsIDB4MDksIDB4MEEsIDB4MEIsIDB4MEMsIDB4MEQsIDB4MEUsIDB4MEYsCiAgICAgICAgICAgIDB4MTAsIDB4MTEsIDB4MTIsIDB4MTMsIDB4MTQsIDB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GVuY3J5cHRlZERhdGEpLlJlcGxhY2UoIi0iLCAiIikuVG9Mb3dlckludmFyaWFudCgpKTsKICAgICAgICAgICAgfQogICAgICAgIH0KCX0KfQ==