Generate SHA1 Hash in Portable Class Library

前端 未结 9 2051
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 23:56

I\'m trying to build a portable class library that generates OAuth urls for other classes/applications to use. This class library using OAuth has to be a portable class libr

9条回答
  •  太阳男子
    2021-01-08 00:56

    This worked for me when I had to achieve the same outcome. You can do this with SHA512 and others too.

    using System.Security.Cryptography;
    
    public static string HashSHA1(this string value)
    {
        using (var sha = SHA1.Create())
        {
           return Convert.ToBase64String(sha.ComputeHash(System.Text.Encoding.UTF8.GetBytes(value)));
        }
    }
    

    Code cited from: https://xamarinhelp.com/cryptography-in-xamarin-forms/

提交回复
热议问题