How do I generate an encryption hash in ASP.NET MVC?

后端 未结 4 1140
一个人的身影
一个人的身影 2021-01-05 16:12

I am looking into creating a custom members login system (for learning) and I haven\'t been able to figure out the C# command to generate an encrypted hash.

Is ther

4条回答
  •  [愿得一人]
    2021-01-05 16:34

    For my part, I purpose this function i use to get the gravatar picture profil:

    you can use it like you want

    public string getGravatarPicture()
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(email.ToLower());
            Byte[] encodedBytes = md5.ComputeHash(originalBytes);
    
            string hash = BitConverter.ToString(encodedBytes).Replace("-", "").ToLower();
            return "http://www.gravatar.com/avatar/"+hash+"?d=mm";
        }
    

提交回复
热议问题