Author: Lord Nikon
Date: October 15, 2005
Well, I tried my hands at making an OCX (ActiveX Control) with VB6 for encryption. I have to say it came out pretty well even though the encryption algorithm is pretty easy to figure out.
I won't give out the source for the OCX file but I'll show you how to use the Control in the VB6.
Ok let's start by first downloading the ZIP file with the OCX in it. Unzip it and put the OCX in the system32 folder of your computer. Make a new standard EXE and press CTRL+T in the components. In the components menu choose NikonEncryption:
Download: ZIP File with OCX file and sample of the program.

Now there will be a new item in the toolbar:

Draw some new controls on the form so it looks something like this:

Name them whatever you want.
In the NikonCrypto1 decrypted event add this code:
Private Sub NikonCrypto1_decrypted(StrDecryptedText As String)
MsgBox "The decrypted message is " + StrDecryptedText, vbOKOnly + vbInformation, "Test Encryption"
End Sub
In the NikonCrypto1 encrypted event add this code:
Private Sub NikonCrypto1_encryption(StrEncryptedText As String)
MsgBox "The encrypted message is " + StrEncryptedText, vbOKOnly + vbInformation, "Test Encryption"
End Sub
Add this in the NikonCrypto1 keychanged event:
Private Sub NikonCrypto1_keychanged()
MsgBox "The new key is " + NikonCrypto1.Key, vbOKOnly + vbInformation, "Test Encryption"
End Sub</b>
In the Encrypt button add this code:
<b>Private Sub cmdencrypt_Click()
NikonCrypto1.Key = txtcryptkey.Text
If Len(txtmessage.Text) > 0 Then
NikonCrypto1.Message = txtmessage.Text
txtcrypt.Text = NikonCrypto1.Encryption
End If
End Sub
What this code does is that it makes the NikonCrypt1 key what you type in the key text box. If someone wrote something in the message box then, that's what the message property of NikonCrypto1. Same goes for the encryption string.
Add this code in the decrypt button:
Private Sub cmddecrypt_Click()
NikonCrypto1.Key = txtcryptkey.Text
If Len(txtcrypt.Text) > 0 Then
NikonCrypto1.Encryption = txtcrypt.Text
txtmessage.Text = NikonCrypto1.Decrypt
End If
End Sub
What this code does is if the someone wrote something in the Encryption text box, that would be the value of the nikoncrypto1 encryption property and same goes for the message and encryption key.
Add this code in the Exit button:
Private Sub cmdclose_Click()
Unload Me
End Sub
Simple just closes the program.
|