Hash and salt passwords in C#

后端 未结 14 1846
野趣味
野趣味 2020-11-22 04:00

I was just going through one of DavidHayden\'s articles on Hashing User Passwords.

Really I can\'t get what he is trying to achieve.

Here is his code:

<
14条回答
  •  花落未央
    2020-11-22 04:19

    In answer to this part of the original question "Is there any other C# method for hashing passwords" You can achieve this using ASP.NET Identity v3.0 https://www.nuget.org/packages/Microsoft.AspNet.Identity.EntityFramework/3.0.0-rc1-final

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.AspNet.Identity;
    using System.Security.Principal;
    
    namespace HashTest{
    
    
        class Program
        {
            static void Main(string[] args)
            {
    
                WindowsIdentity wi = WindowsIdentity.GetCurrent();
    
                var ph = new PasswordHasher();
    
                Console.WriteLine(ph.HashPassword(wi,"test"));
    
                Console.WriteLine(ph.VerifyHashedPassword(wi,"AQAAAAEAACcQAAAAEA5S5X7dmbx/NzTk6ixCX+bi8zbKqBUjBhID3Dg1teh+TRZMkAy3CZC5yIfbLqwk2A==","test"));
    
            }
        }
    
    
    }
    

提交回复
热议问题