Using the SHA-3 algorithm in Blazor Server

64 Views Asked by At

I am writing an application that will salt passwords using the SHA-3 algorithm. I am writing the application in C#, .NET 8 technology and Blazor Server. For SHA-3 it uses the SHA3.NET library. As a result, I do not receive a hash, which, given the same set of data, gives a hash in the form: 9uBnQbETH5V7FMDtk-6x, but I receive a hash:��Gc�����_}Hؼ�.&�����1lrh)���$\���r��#����U�#c�. This looks like a coding problem to me, or maybe I'm using the library mentioned incorrectly.

This is a class that uses the mentioned library and returns a string.

using SHA3.Net;
using System.Text;

namespace SaltedPasswordGenerator.Crypto
{
    public class SHA3Crypto : IDisposable
    {
        private Sha3 sh;
        public SHA3Crypto()
        {
            sh = Sha3.Sha3512();
        }

        public void Dispose()
        {
            sh = null;
        }

        public string GetHash(string value)
        {
            byte[] val = Encoding.UTF8.GetBytes(value);
            byte[] hash = sh.ComputeHash(val);
            return Encoding.UTF8.GetString(hash);
        }
    }
}

Could someone point me to a solution or a direction to go?

0

There are 0 best solutions below