using System.Security.Cryptography;
using System.Text;

namespace Helpers.Encryption
{
    public class Hash
    {
        public static string HashString(string stringToHash)
        {
            //var shaEngine = new SHA3.SHA3Managed(512);
            //var hash = shaEngine.ComputeHash(Encoding.Unicode.GetBytes(stringToHash));
            //return Encoding.Unicode.GetString(hash);

            MD5 md5 = MD5.Create();

            byte[] inputBytes = Encoding.ASCII.GetBytes(stringToHash);

            byte[] hash = md5.ComputeHash(inputBytes);
            
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < hash.Length; i++)
            {
                sb.Append(hash[i].ToString("X2"));
            }

            return sb.ToString();
        }
    }
}
