Convert any string to a SHA 512 Hashed String

Sha 512 is a high security module, and the length of the generated string has about 130 characters.

Here is the definition for the extension.

        public static string ToHashedString(this string inputString)
            var crypt = new SHA512Managed();
            //var crypt = new SHA256Managed();
            string hash = String.Empty;
            byte[] crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(inputString), 0, Encoding.UTF8.GetByteCount(inputString));
            return crypto.Aggregate(hash, (current, bit) => current + bit.ToString("x2"));

Comments are closed.