using System;
using System.Security.Cryptography;
public void CreateKey1(out string iv, out string key)
{
var BLOCK_SIZE = 128; // 128bit 固定
var KEY_SIZE = 256; // 128/192/256bit から選択
// AES暗号サービスを生成
var csp = new AesCryptoServiceProvider();
csp.BlockSize = BLOCK_SIZE;
csp.KeySize = KEY_SIZE;
csp.Mode = CipherMode.CBC;
csp.Padding = PaddingMode.PKCS7;
// IV および 鍵 を自動生成
csp.GenerateIV();
csp.GenerateKey();
// 鍵を出力;
string iv = Convert.ToBase64String(csp.IV);
string key = Convert.ToBase64String(csp.Key);
}