patbef-ServiceOutside/ServiceOutsideTests/Crypto/MD5.cs

31 lines
997 B
C#
Raw Normal View History

2024-01-29 16:27:34 +01:00
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 MD5
{
[Test]
public void EncryptDecrypt()
{
Assert.IsTrue(ServiceShared.Crypto.MD5.Encrypt("dasd hsadhuiahdiashd uihas uidhasi hdiuashd uihasid asd asd sa") == "63754a7803f653217f6b46e048e5c286");
Assert.IsTrue(ServiceShared.Crypto.MD5.Encrypt("Hello world") == "3e25960a79dbc69b674cd4ec67a72c62");
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);
Assert.IsTrue(ServiceShared.Crypto.MD5.Encrypt(key).Length == 32);
}
}
}
}