blob: dcf69007d4069da8602b61cb9ca4b6f8161922cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace VNLib.Hashing.Tests
{
[TestClass()]
public class VnArgon2Tests
{
private static string LocalArgon2Lib = "../../../../../Utils.Cryptography/argon2/build/Debug/Argon2";
[TestInitialize]
public void InitDefaultLibPath()
{
Environment.SetEnvironmentVariable(VnArgon2.ARGON2_LIB_ENVIRONMENT_VAR_NAME, LocalArgon2Lib);
}
[TestMethod]
public void LoadLibraryTest()
{
//shared lib should load without issue
_ = VnArgon2.GetOrLoadSharedLib();
}
[TestMethod]
public void Argon2IdHashTest()
{
const string RawPass = "HelloWorld1!*";
const string SaltHex = "de7cdb9d59828ac9";
const string PepperHex = "13fe89892162d477";
const string KnownOutput = "";
const uint HashSize = 64u;
Argon2CostParams a2Params = new()
{
MemoryCost = 65535,
Parallelism = 4,
TimeCost = 2,
};
IArgon2Library lib = VnArgon2.GetOrLoadSharedLib();
string passHash = lib.Hash2id(
password: RawPass,
salt: Convert.FromHexString(SaltHex),
secret: Convert.FromHexString(PepperHex),
costParams: in a2Params,
hashLen: HashSize
);
Console.WriteLine(passHash);
}
}
}
|