mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Added more tests
Code cleanup in Lib WIP new VM for OpendatabaseControl WIP KDBX4 file save - still not working
This commit is contained in:

committed by
BONNEVILLE Geoffroy

parent
278b2759d5
commit
53a54252e3
@@ -68,7 +68,7 @@ namespace ModernKeePassLib.Test.Cryptography.Hash
|
||||
}
|
||||
}
|
||||
|
||||
public static string ByteToString(byte[] buff)
|
||||
private static string ByteToString(byte[] buff)
|
||||
{
|
||||
string sbinary = "";
|
||||
|
||||
|
42
ModernKeePassLib.Test/Cryptography/Hash/SHAManagedTests.cs
Normal file
42
ModernKeePassLib.Test/Cryptography/Hash/SHAManagedTests.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using ModernKeePassLib.Cryptography.Hash;
|
||||
using ModernKeePassLib.Utility;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace ModernKeePassLib.Test.Cryptography.Hash
|
||||
{
|
||||
[TestFixture]
|
||||
public class SHAManagedTests
|
||||
{
|
||||
[Test]
|
||||
public void TestSha256ComputeHash()
|
||||
{
|
||||
var expectedHash = "B822F1CD2DCFC685B47E83E3980289FD5D8E3FF3A82DEF24D7D1D68BB272EB32";
|
||||
var message = StrUtil.Utf8.GetBytes("testing123");
|
||||
using (var result = new SHA256Managed())
|
||||
{
|
||||
Assert.That(ByteToString(result.ComputeHash(message)), Is.EqualTo(expectedHash));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSha512ComputeHash()
|
||||
{
|
||||
var expectedHash = "4120117B3190BA5E24044732B0B09AA9ED50EB1567705ABCBFA78431A4E0A96B1152ED7F4925966B1C82325E186A8100E692E6D2FCB6702572765820D25C7E9E";
|
||||
var message = StrUtil.Utf8.GetBytes("testing123");
|
||||
using (var result = new SHA512Managed())
|
||||
{
|
||||
Assert.That(ByteToString(result.ComputeHash(message)), Is.EqualTo(expectedHash));
|
||||
}
|
||||
}
|
||||
private static string ByteToString(byte[] buff)
|
||||
{
|
||||
string sbinary = "";
|
||||
|
||||
for (int i = 0; i < buff.Length; i++)
|
||||
{
|
||||
sbinary += buff[i].ToString("X2"); // hex format
|
||||
}
|
||||
return (sbinary);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,13 +1,7 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
|
||||
#if KeePassLib
|
||||
using KeePassLib.Cryptography;
|
||||
#else
|
||||
using ModernKeePassLib.Cryptography;
|
||||
#endif
|
||||
|
||||
namespace ModernKeePassLib.Test.Cryptography
|
||||
{
|
||||
|
Reference in New Issue
Block a user