Exemple #1
0
        private async Task <byte[]> GetPasswordHash(string password)
        {
            var argon2 = new Argon2i(Encoding.UTF8.GetBytes(password))
            {
                DegreeOfParallelism = 8,
                MemorySize          = 4096,
                Iterations          = 40
            };

            return(await argon2.GetBytesAsync(128));
        }
Exemple #2
0
        public async Task <string> Argon2HashAsync(string text, int iterations = 50, int degreeOfParallelism = 8,
                                                   int memorySize = 8192)
        {
            using (var a = new Argon2i(Encoding.UTF8.GetBytes(text)))
            {
                a.DegreeOfParallelism = degreeOfParallelism;
                a.MemorySize          = memorySize;
                a.Iterations          = iterations;
                a.Salt           = Encoding.UTF8.GetBytes(Strongify(text));
                a.AssociatedData = Encoding.UTF8.GetBytes(Strongify(text));
                var b = await a.GetBytesAsync(512 / 8);

                return(BitConverter.ToString(b).Replace("-", "").ToLower());
            }
        }