Hash string in c#

前端 未结 7 1515
栀梦
栀梦 2020-12-07 10:30

I have a problem when trying get a hash string in c#.

I already tried a few websites, but most of them are using files to get the hash. Others that are

相关标签:
7条回答
  • 2020-12-07 11:08

    The shortest and fastest way ever. Only 1 line!

        public static string StringSha256Hash(string text) =>
            string.IsNullOrEmpty(text) ? string.Empty : BitConverter.ToString(new System.Security.Cryptography.SHA256Managed().ComputeHash(System.Text.Encoding.UTF8.GetBytes(text))).Replace("-", string.Empty);
    
    0 讨论(0)
提交回复
热议问题