Calculate-string-Hash-using-MD5-SHA1-SHA256-SHA512 - WeOnlyDo Software example code



All

wodCrypt (12)
wodSSH (10)
wodSFTP (23)
wodSSHServer (1)
wodSSHTunnel (11)
wodSSHpackage
wodSFTPdll

wodSSH.NET (10)
wodSFTP.NET (24)
wodFtpDLX.NET (22)
wodWebServer.NET (10)

wodAppUpdate (13)
wodHttpDLX (8)
wodFtpDLX (22)
wodTelnetDLX
wodFTPServer (3)
wodWebServer (10)
wodVPN
wodXMPP (13)
All ** [Visual Basic] ** [C#] ** [VB.NET] **

Calculate string Hash using: MD5, SHA1, SHA256 and SHA512
VB code
Dim wodCrypt1 As wodCryptCom
Set wodCrypt1 = New wodCryptCom
Dim srcmem As New MemBlob
Dim destmem As New MemBlob

'Calculate MD5 hash.
wodCrypt1.Type = MD5
srcmem.Text = "put some text here and calculate hash" 'Insert some data in MemBlob
wodCrypt1.Digest srcmem, destmem
Debug.Print "MD5: " & destmem.ToHex

'Calculate SHA1 hash.
wodCrypt1.Type = SHA1
srcmem.Text = "put some text here and calculate hash"
wodCrypt1.Digest srcmem, destmem
Debug.Print "SHA1: " & destmem.ToHex

'Calculate SHA256 hash.
wodCrypt1.Type = SHA256
srcmem.Text = "put some text here and calculate hash"
wodCrypt1.Digest srcmem, destmem
Debug.Print "SHA256: " & destmem.ToHex

'Calculate SHA512 hash.
wodCrypt1.Type = SHA512
srcmem.Text = "put some text here and calculate hash"
wodCrypt1.Digest srcmem, destmem
Debug.Print "SHA512: " & destmem.ToHex
VB.NET code
Dim wodCrypt1 As WODCRYPTCOMLib.wodCryptCom
wodCrypt1 = New WODCRYPTCOMLib.wodCryptCom
Dim srcmem As New WODCRYPTCOMLib.MemBlob
Dim destmem As New WODCRYPTCOMLib.MemBlob

'Calculate MD5 hash.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.MD5
srcmem.Text = "put some text here and calculate hash" 'Insert some data in MemBlob
wodCrypt1.Digest(srcmem, destmem)
Console.WriteLine("MD5: " & destmem.ToHex)

'Calculate SHA1 hash.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.SHA1
srcmem.Text = "put some text here and calculate hash"
wodCrypt1.Digest(srcmem, destmem)
Console.WriteLine("SHA1: " & destmem.ToHex)

'Calculate SHA256 hash.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.SHA256
srcmem.Text = "put some text here and calculate hash"
wodCrypt1.Digest(srcmem, destmem)
Console.WriteLine("SHA256: " & destmem.ToHex)

'Calculate SHA512 hash.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.SHA512
srcmem.Text = "put some text here and calculate hash"
wodCrypt1.Digest(srcmem, destmem)
Console.WriteLine("SHA512: " & destMem.ToHex)
C# code
WODCRYPTCOMLib.wodCryptCom wodCrypt1;
wodCrypt1 = new WODCRYPTCOMLib.wodCryptCom();
WODCRYPTCOMLib.MemBlob srcmem = new WODCRYPTCOMLib.MemBlob();
WODCRYPTCOMLib.MemBlob destmem = new WODCRYPTCOMLib.MemBlob();

//Calculate MD5 hash.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.MD5;
srcmem.Text = "put some text here and calculate hash"; //'Insert some data in MemBlob
wodCrypt1.Digest((WODCRYPTCOMLib.Blob)srcmem, (WODCRYPTCOMLib.Blob)destmem);
Console.WriteLine("MD5: " + destmem.ToHex());

//Calculate SHA1 hash.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.SHA1;
srcmem.Text = "put some text here and calculate hash";
wodCrypt1.Digest((WODCRYPTCOMLib.Blob)srcmem, (WODCRYPTCOMLib.Blob)destmem);
Console.WriteLine("SHA1: " + destmem.ToHex());

//Calculate SHA256 hash.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.SHA256;
srcmem.Text = "put some text here and calculate hash";
wodCrypt1.Digest((WODCRYPTCOMLib.Blob)srcmem, (WODCRYPTCOMLib.Blob)destmem);
Console.WriteLine("SHA256: " + destmem.ToHex());

//Calculate SHA512 hash.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.SHA512;
srcmem.Text = "put some text here and calculate hash";
wodCrypt1.Digest((WODCRYPTCOMLib.Blob)srcmem, (WODCRYPTCOMLib.Blob)destmem);
Console.WriteLine("SHA512: " + destmem.ToHex());