30 lines
944 B
Plaintext
30 lines
944 B
Plaintext
|
using NUnit.Framework;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Security.Cryptography;
|
||
|
using System.Text;
|
||
|
using System.Threading.Tasks;
|
||
|
|
||
|
namespace ServiceOutsideTests.Crypto
|
||
|
{
|
||
|
public class AES
|
||
|
{
|
||
|
[Test]
|
||
|
public void EncryptDecrypt()
|
||
|
{
|
||
|
for(int i = 0; i < 1000; i++)
|
||
|
{
|
||
|
int KeySize = new Random().Next(1, 4096);
|
||
|
byte[] random = new byte[KeySize];
|
||
|
RandomNumberGenerator.Fill(random);
|
||
|
string key = Encoding.UTF8.GetString(random);
|
||
|
string input = "Hello World";
|
||
|
string encrypted = ServiceShared.Crypto.AES.Encrypt(input, ServiceShared.Crypto.AES.GetKey(key));
|
||
|
string decrypted = ServiceShared.Crypto.AES.Decrypt(encrypted, ServiceShared.Crypto.AES.GetKey(key));
|
||
|
Assert.AreEqual(input, decrypted);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|