public async Task Encrypte() { //if (txtKey.Text == "" && txtIv.Text == "") //{ // await GenerateKey(); //} (byte[] value, byte[] key, byte[] iv)? info = await Check(txtSource.Text, true); if (info.HasValue) { byte[] result = null; var cipherMode = CipherMode; var paddingMode = PaddingMode; await Task.Run(() => { C.Aes aes = new C.Aes(); aes.Manager.Key = info.Value.key; aes.Manager.IV = info.Value.iv; aes.Manager.Mode = cipherMode; aes.Manager.Padding = paddingMode; result = aes.Encrypt(info.Value.value); }); txtResult.Text = await GetString(result, BinaryOutputMode); } }
public async Task Decrypte() { (byte[] value, byte[] key, byte[] iv)? info = await Check(txtResult.Text, false); if (info.HasValue) { byte[] result = null; var cipherMode = CipherMode; var paddingMode = PaddingMode; await Task.Run(() => { C.Aes aes = new C.Aes(); aes.Manager.Key = info.Value.key; aes.Manager.IV = info.Value.iv; aes.Manager.Mode = cipherMode; aes.Manager.Padding = paddingMode; result = aes.Decrypt(info.Value.value); }); txtSource.Text = Encoding.GetString(result); } }