I have error about System.Memory when trying use Sha256 function

17 views
Skip to first unread message

Toro Bunny

unread,
Jan 18, 2022, 3:46:56 AMJan 18
to rextester
_____ My Code _____
            static string ComputeSha256Hash(string rawData)
                        {
                                using (SHA256 sha256Hash = SHA256.Create())
                                {
                                        byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));

                                        StringBuilder builder = new StringBuilder();
                                        for (int i = 0; i < bytes.Length; i++)
                                        {
                                                builder.Append(bytes[i].ToString("x2"));
                                        }
                                        return builder.ToString();
                                }
                        }
_____ Error _____
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Memory, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. An internal error occurred. (0x8007054F) File name: 'System.Memory, Version=4.2.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' at Internal.Cryptography.HashProviderDispenser.EvpHashProvider.AppendHashData(ReadOnlySpan`1 data) at Internal.Cryptography.HashProvider.AppendHashData(Byte[] data, Int32 offset, Int32 count) at System.Security.Cryptography.SHA256.Implementation.HashCore(Byte[] array, Int32 ibStart, Int32 cbSize) at System.Security.Cryptography.HashAlgorithm.ComputeHash(Byte[] buffer) at Rextester.Program.<TryHash>g__ComputeSha256Hash|2_0(String rawData) at Rextester.Program.TryHash(List`1 list) at Rextester.Program.Main(String[] args)



Reply all
Reply to author
Forward
0 new messages