C#SHA512
示例
using System; using System.Security.Cryptography; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string source = "你好,世界!"; using (SHA512 sha512Hash = SHA512.Create()) { //从字符串到字节数组 byte[] sourceBytes = Encoding.UTF8.GetBytes(source); byte[] hashBytes = sha512Hash.ComputeHash(sourceBytes); string hash = BitConverter.ToString(hashBytes).Replace("-", String.Empty); Console.WriteLine("的SHA512哈希 " + source + " is: " + hash); } } } }
输出:HelloWorld的SHA512哈希!是:861844D6704E8573FEC34D967E20BCFEF3D424CF48BE04E6DC08F2BD58C729743371015EAD891CC3CF1C9D34B49264B510751B1FF9E537937BC46B5D6FF4ECC8