patbef-ServiceOutside/ServiceOutside/Documents/Datenschutz-Audit/Crypto_Codes_with_Unittests/UnitTests/SHA512.txt

34 lines
1.2 KiB
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 SHA512
{
[Test]
public void Encrypt()
{
Assert.IsTrue(ServiceShared.Crypto.SHA512.Encrypt("dasd hsadhuiahdiashd uihas uidhasi hdiuashd uihasid asd asd sa") == "a93500a760ec2ad79d540bea6828fc8e740d7a9c63cd0b7911486949051df53a36438887827e05d3f23a57fc4c149b6f6323d63ffc92c63be35a06108b3d6155");
Assert.IsTrue(ServiceShared.Crypto.SHA512.Encrypt("Hello world") == "b7f783baed8297f0db917462184ff4f08e69c2d5e5f79a942600f9725f58ce1f29c18139bf80b06c0fff2bdd34738452ecf40c488c22a7e3d80cdf6f9c1c0d47");
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.SHA512.Encrypt(key).Length == 128);
}
}
[Test]
}
}