Kodun yazıldığı sistem..: Pentium II 333Mhz, 64Mb ram
İşletim Sistemi.............: MS WindowsNT 4.0, Service Pack 5
Version.......................: MS Visual Basic 6.0 Enterprise

Bu activex orneğinde verilen bir textin şifrelenmesini sağlıyacak bir OCX yapacağız. Bir Activex Kontrol projesi başlatarak aşağıdaki kodu User kontrol icine yapıştırın.

Private Result As String
Private Code As Integer
Private AssRes As String

Public Function Encrypt(StrEnc As String, IntVal As Integer) As String
If inval > 128 Then IntVal = 128
AssRes = ""
For i = 1 To Len(StrEnc)
Result = Mid$(StrEnc, i, 1)
Code = Asc(Result)
Code = Code + Int(IntVal)
If Code > 255 Then
Code = Code - 255
End If
AssRes = AssRes & Chr$(Code)
Next i
Encrypt = AssRes
End Function

Public Function Decrypt(StrEnc As String, IntVal As Integer) As String
If inval > 128 Then IntVal = 128
AssRes = ""
For i = 1 To Len(StrEnc)
Result = Mid$(StrEnc, i, 1)
Code = Asc(Result)
Code = Code - Int(IntVal)
If Code > 255 Then
Code = Code - 255
End If
AssRes = AssRes & Chr$(Code)
Next i
Decrypt = AssRes
End Function


Gorulduğu gibi sadece 2 adet fonksiyonumuz var ve bunlar textleri şifrelemek icin kullanılıyor. Şimdi File menusunden make XXXXXX.ocx seceneği ile ocx dosyamızı oluşturalım. Guzel bir isimde vermeyi unutmayın. Ocx oluştuktan sonra yeni bir exe projesi acın ve yarattığınız OCX dosyasını components kısmına ekleyin. Formun uzerine 3 adet edit box ve 2 adet buton koyun. Tabii ki yarattığınız OCX dosyasınıda koymayı unutmayın. Şimdi ilk text box'a yazacağımız text 1. buton ile şifrelenerek 2. text box'a gelecek ve şifreyi acmak icinde diğre butonu kullanıcaz. O zamanda şifrelenmiş text eski hali ile 3. text box'da gorunecek. Kolay gelsin
__________________