SHA512 C# with Example



SHA512 C# with Example

using System; 
using System.Security.Cryptography; 
using System.Text; 
namespace ConsoleApplication1 
{ 
class Program 
{ 
static void Main(string[] args) 
{ 
string source = "Hello World!"; 
using (SHA512 sha512Hash = SHA512.Create()) 
{ 
//From String to byte array 
byte[] sourceBytes = Encoding.UTF8.GetBytes(source); 
byte[] hashBytes = sha512Hash.ComputeHash(sourceBytes); 
string hash = BitConverter.ToString(hashBytes).Replace("-", String.Empty); 
Console.WriteLine("The SHA512 hash of " + source + " is: " + hash); 
} 
} 
} 
} 
Output: The SHA512 hash of Hello World! is: 
861844D6704E8573FEC34D967E20BCFEF3D424CF48BE04E6DC08F2BD58C729743371015EAD891CC3CF1C9D34B49 
264B510751B1FF9E537937BC46B5D6FF4ECC8 
 

in C# 
Parameters Details 
A value for generating random numbers. If not set, the default value is determined by the current 
Seed 
system time. 
minValue Generated numbers won't be smaller than this value. If not set, the default value is 0. 
maxValue Generated numbers will be smaller than this value. If not set, the default value is Int32.MaxValue. 
return value Returns a number with random value. 

0 Comment's

Comment Form

Submit Comment