Encrypt-and-decrypt-string - 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] **

Encrypt and decrypt string
VB code
Dim wodCrypt1 As wodCryptCom
Set wodCrypt1 = New wodCryptCom
Dim inBlobEncrypt As MemBlob
Set inBlobEncrypt = New MemBlob
Dim outBlobEncrypt As MemBlob
Set outBlobEncrypt = New MemBlob

'First we will add some text inside MemBlob for encryption."
inBlobEncrypt.Text = "This is text that will be encrypted!"

'Using SecretKey Property we will add some secret password.
wodCrypt1.SecretKey = "WeOnlyDo!"
'Optimized set to True should be used when you use wodCrypt in both direction. For encryption and decryption.
'When Optimized is set to True you don't need to worry about blob size of encrypted data.
wodCrypt1.Optimized = True
'Select which algorithm you want to use for encryption process.
wodCrypt1.Type = Blowfish
'Finally encrypt MemBlob using Encrypt Method.
wodCrypt1.Encrypt inBlobEncrypt, outBlobEncrypt
'Print encrypted result.
Debug.Print outBlobEncrypt.Text


Dim wodCrypt2 As wodCryptCom
Set wodCrypt2 = New wodCryptCom
Dim inBlobDecrypt As MemBlob
Set inBlobDecrypt = New MemBlob
Dim outBlobDecrypt As MemBlob
Set outBlobDecrypt = New MemBlob

'We will decrypt same data that we encrypt previously in this example.
inBlobDecrypt.Text = outBlobEncrypt.Text

'Make sure that same settings you are using during encryption is used during decryption process.
wodCrypt1.SecretKey = "WeOnlyDo!"
wodCrypt1.Optimized = True
wodCrypt1.Type = Blowfish
'Decrypt Method is used for decryption.
wodCrypt1.Decrypt inBlobDecrypt, outBlobDecrypt
'Print decrypted result.
Debug.Print outBlobDecrypt.Text
VB.NET code
Dim wodCrypt1 As WODCRYPTCOMLib.wodCryptCom
wodCrypt1 = New WODCRYPTCOMLib.wodCryptCom
Dim inBlobEncrypt As WODCRYPTCOMLib.MemBlob
inBlobEncrypt = New WODCRYPTCOMLib.MemBlob
Dim outBlobEncrypt As WODCRYPTCOMLib.MemBlob
outBlobEncrypt = New WODCRYPTCOMLib.MemBlob

'First we will add some text inside MemBlob for encryption.
inBlobEncrypt.Text = "This is text that will be encrypted!"

'Using SecretKey Property we will add some secret password.
wodCrypt1.SecretKey = "WeOnlyDo!"
'Optimized set to True should be used when you use wodCrypt in both direction. For encryption and decryption.
'When Optimized is set to True you don't need to worry about blob size of encrypted data.
wodCrypt1.Optimized = True
'Select which algorithm you want to use for encryption process.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.Blowfish
'Finally encrypt MemBlob using Encrypt Method.
wodCrypt1.Encrypt(inBlobEncrypt, outBlobEncrypt)
'Print encrypted result.
Console.WriteLine(outBlobEncrypt.Text)


Dim wodCrypt2 As WODCRYPTCOMLib.wodCryptCom
wodCrypt2 = New WODCRYPTCOMLib.wodCryptCom
Dim inBlobDecrypt As WODCRYPTCOMLib.MemBlob
inBlobDecrypt = New WODCRYPTCOMLib.MemBlob
Dim outBlobDecrypt As WODCRYPTCOMLib.MemBlob
outBlobDecrypt = New WODCRYPTCOMLib.MemBlob

'We will decrypt same data that we encrypt previously in this example.
inBlobDecrypt.Text = outBlobEncrypt.Text

'Make sure that same settings you are using during encryption is used during decryption process.
wodCrypt1.SecretKey = "WeOnlyDo!"
wodCrypt1.Optimized = True
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.Blowfish
'Decrypt Method is used for decryption.
wodCrypt1.Decrypt(inBlobDecrypt, outBlobDecrypt)
'Print decrypted result.
Console.WriteLine(outBlobDecrypt.Text)
C# code
WODCRYPTCOMLib.wodCryptCom wodCrypt1;
wodCrypt1 = new WODCRYPTCOMLib.wodCryptCom();
WODCRYPTCOMLib.MemBlob inBlobEncrypt;
inBlobEncrypt = new WODCRYPTCOMLib.MemBlob();
WODCRYPTCOMLib.MemBlob outBlobEncrypt;	
outBlobEncrypt = new WODCRYPTCOMLib.MemBlob();

//First we will add some text inside MemBlob for encryption.
inBlobEncrypt.Text = "this is text that will be encrypted";

//Using SecretKey Property we will add some secret password.
wodCrypt1.SecretKey = "WeOnlyDo!";
//Optimized set to True should be used when you use wodCrypt in both direction. For encryption and decryption.
//When Optimized is set to True you don't need to worry about blob size of encrypted data.
wodCrypt1.Optimized = true;
//Select which algorithm you want to use for encryption process.
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.Blowfish;
//Finally encrypt MemBlob using Encrypt Method.
wodCrypt1.Encrypt((WODCRYPTCOMLib.Blob)inBlobEncrypt, (WODCRYPTCOMLib.Blob)outBlobEncrypt);
//Print encrypted result.
Console.WriteLine(outBlobEncrypt.Text);


WODCRYPTCOMLib.wodCryptCom wodCrypt2;
wodCrypt2 = new WODCRYPTCOMLib.wodCryptCom();
WODCRYPTCOMLib.MemBlob inBlobDecrypt;
inBlobDecrypt = new WODCRYPTCOMLib.MemBlob();
WODCRYPTCOMLib.MemBlob outBlobDecrypt;
outBlobDecrypt = new WODCRYPTCOMLib.MemBlob();

//We will decrypt same data that we encrypt previously in this example.
inBlobDecrypt.Text = outBlobEncrypt.Text;

//Make sure that same settings you are using during encryption is used during decryption process.
wodCrypt1.SecretKey = "WeOnlyDo!";     
wodCrypt1.Optimized = true;
wodCrypt1.type = WODCRYPTCOMLib.CryptoTypes.Blowfish;
//Decrypt Method is used for decryption.
wodCrypt1.Decrypt((WODCRYPTCOMLib.Blob)inBlobDecrypt, (WODCRYPTCOMLib.Blob)outBlobDecrypt);
//Print decrypted result.	
Console.WriteLine(outBlobDecrypt.Text);