Sign-a-string-using-private-key - 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] **

Sign a string using private key
VB code
Dim wodCrypt1 As wodCryptCom
Set wodCrypt1 = New wodCryptCom
Dim OriginalBlob As MemBlob
Dim SignatureBlob As MemBlob
Set OriginalBlob = New MemBlob
Set SignatureBlob = New MemBlob
Dim key As New Keys

'First we need to load RSA or DSA private key in wodKeys.
'wodKeys component comes with wodCrypt ActiveX component.
key.Load "c:\RSA_private_key.key"

OriginalBlob.Text = "This is text that we want to sign"

'Choice RSA or DSA private key type.
wodCrypt1.Type = RSA
'Add some padding for input blocks with incorrect size.
wodCrypt1.Padding = PadPKCS7
'Load private key from wodKeys in wodCrypt.
wodCrypt1.SecretKey = key
'Finally sign memory blob using Sign Method.
wodCrypt1.Sign OriginalBlob, SignatureBlob

Debug.Print SignatureBlob.ToHex
VB.NET code
Dim wodCrypt1 As WODCRYPTCOMLib.wodCryptCom
wodCrypt1 = New WODCRYPTCOMLib.wodCryptCom
Dim OriginalBlob As WODCRYPTCOMLib.MemBlob
Dim SignatureBlob As WODCRYPTCOMLib.MemBlob
OriginalBlob = New WODCRYPTCOMLib.MemBlob
SignatureBlob = New WODCRYPTCOMLib.MemBlob
Dim key As New wodKeys.Keys

'First we need to load RSA or DSA private key in wodKeys.
'wodKeys component comes with wodCrypt ActiveX component.
key.Load("c:\RSA_private_key.key")

OriginalBlob.Text = "This is text that we want to sign"

'Choice RSA or DSA private key type.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.RSA
'Add some padding for input blocks with incorrect size.
wodCrypt1.Padding = WODCRYPTCOMLib.CryptoPadding.PadPKCS7
'Load private key from wodKeys in wodCrypt.
wodCrypt1.SecretKey = key
'Finally sign memory blob using Sign Method.
wodCrypt1.Sign(OriginalBlob, SignatureBlob)

Console.WriteLine(SignatureBlob.ToHex)
C# code
WODCRYPTCOMLib.wodCryptCom wodCrypt1;
wodCrypt1 = new WODCRYPTCOMLib.wodCryptCom();
WODCRYPTCOMLib.MemBlob OriginalBlob;
WODCRYPTCOMLib.MemBlob SignatureBlob;
OriginalBlob = new WODCRYPTCOMLib.MemBlob();
SignatureBlob = new WODCRYPTCOMLib.MemBlob();
wodKeys.Keys key = new wodKeys.Keys();

//First we need to load RSA or DSA private key in wodKeys.
//wodKeys component comes with wodCrypt ActiveX component.
key.Load("c:\\c:\RSA_private_key.key", null);

OriginalBlob.Text = "This is text that we want to sign";

//Choice RSA or DSA private key type
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.RSA;
//Add some padding for input blocks with incorrect size.
wodCrypt1.Padding = WODCRYPTCOMLib.CryptoPadding.PadPKCS7;
//Load private key from wodKeys in wodCrypt.
wodCrypt1.SecretKey = key;
//Finally sign memory blob using Sign Method.
wodCrypt1.Sign((WODCRYPTCOMLib.Blob)OriginalBlob, (WODCRYPTCOMLib.Blob)SignatureBlob);

Console.WriteLine(SignatureBlob.ToHex());