using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Konscious.Security.Cryptography; public partial class argon2 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var password = "Hello World!"; var salt = CreateSalt(); var hash = HashPassword(password, salt); Response.Write(hash); } private byte[] CreateSalt() { var buffer = new byte[16]; var rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); rng.GetBytes(buffer); return buffer; } private byte[] HashPassword(string password, byte[] salt) { var argon2 = new Argon2d(Encoding.UTF8.GetBytes(password)); argon2.Salt = salt; argon2.DegreeOfParallelism = 4; // four cores argon2.Iterations = 1; argon2.MemorySize = 1024 * 1024; // 1 GB return argon2.GetBytes(16); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)