static void Main(string[] args) { var password = "******"; var salt = Encoding.UTF8.GetBytes("and this is a salt"); var sw = new Stopwatch(); if (args.Length == 0 || args[0] == "scrypt") { sw.Start(); var key = Scrypt.Derive(password, salt, 1048576, 8, 1, 32); sw.Stop(); Console.WriteLine($"Scrypt: {key.ToHexString()}"); Console.WriteLine($"Scrypt: {sw.ElapsedMilliseconds}"); } if (args.Length == 0 || args[0] == "sse") { sw.Restart(); var key = ScryptSse.Derive(password, salt, 1048576, 8, 1, 32); sw.Stop(); Console.WriteLine($"ScryptSse: {key.ToHexString()}"); Console.WriteLine($"ScryptSse: {sw.ElapsedMilliseconds}"); } }
public void Test2() { var password = "******"; var salt = new byte[64]; var rng = RandomNumberGenerator.Create(); rng.GetNonZeroBytes(salt); for (var a = 4; a < 10; ++a) { var sseKey = ScryptSse.Derive(password, salt, 1 << a, 8, 1, 64); var scryptKey = Scrypt.Derive(password, salt, 1 << a, 8, 1, 64); Assert.AreEqual(scryptKey.ToHexString(), sseKey.ToHexString()); } }
public void Test1() { var key = ScryptSse.Derive("pleaseletmein", Encoding.UTF8.GetBytes("SodiumChloride"), 16, 8, 1, 64); var result = new byte[] { 0x25, 0xa9, 0xfa, 0x20, 0x7f, 0x87, 0xca, 0x09, 0xa4, 0xef, 0x8b, 0x9f, 0x77, 0x7a, 0xca, 0x16, 0xbe, 0xb7, 0x84, 0xae, 0x18, 0x30, 0xbf, 0xbf, 0xd3, 0x83, 0x25, 0xaa, 0xbb, 0x93, 0x77, 0xdf, 0x1b, 0xa7, 0x84, 0xd7, 0x46, 0xea, 0x27, 0x3b, 0xf5, 0x16, 0xa4, 0x6f, 0xbf, 0xac, 0xf5, 0x11, 0xc5, 0xbe, 0xba, 0x4c, 0x4a, 0xb3, 0xac, 0xc7, 0xfa, 0x6f, 0x46, 0x0b, 0x6c, 0x0f, 0x47, 0x7b }; Assert.AreEqual(result.ToHexString(), key.ToHexString()); }