-5

I have this "mac key" and other parameter and I need it turned into SHA512

I really need working example code too

I've gathered that it might have something to do with System.Security.Cryptography's SHA512Managed class, but I don't understand how to use that class for a c sharp website at all it makes no sense to me that is why I need a working example of it turning a string into SHA512

lingers
  • 3
  • 1
  • 8

1 Answers1

0

This is for sha256, guess you could turn it into sha512 easily. Hope this will do the trick :)

using System.Security.Cryptography;

    public static String HashPassword(string p, string s)
    {
        var combinedPassword = String.Concat(p, s);
        var sha256 = new SHA256Managed();
        var bytes = UTF8Encoding.UTF8.GetBytes(combinedPassword);
        var hash = sha256.ComputeHash(bytes);
        return Convert.ToBase64String(hash);
    }

    public static String GetRandomSalt(Int32 size)
    {
        var random = new RNGCryptoServiceProvider();
        var salt = new Byte[size];
        random.GetBytes(salt);
        return Convert.ToBase64String(salt);
    }
Melvin
  • 77
  • 1
  • 10