You are on page 1of 2

DEVELOP A COMPONENT FOR CRYPTOGRAPHY USING COM/.NET AIM: To Develop a component for cryptography using COM/.

NET DESCRIPTION:
PART 1 CREATE A COMPONENT 1. Start the process open VS .NET File-> New-> Project-> visual Basic Project -> class library, rename the class Library if required v. include the following coding in the class Library Public Class Class1 Dim pa1 As String Dim i As Integer Dim ct As Long Public Function enco(ByVal pa As String) As String pa1 = pa pa = "" For i = 0 To pa1.Length - 1 ct = Convert.ToInt64(Convert.ToChar(pa1.Substring(i, 1))) ct = ct + ct pa = pa + Convert.ToChar(ct) Next Return (pa) End Function Public Function deco(ByVal pa As String) As String pa1 = pa pa = "" For i = 0 To pa1.Length - 1 ct = Convert.ToInt64(Convert.ToChar(pa1.Substring(i, 1))) ct = ct / 2 pa = pa + Convert.ToChar(ct) Next Return (pa) End Function End Class vi. Build->Build the solution Note: Register the dll using regsvr32 tool or copy the dll to c:\windows\system32. iii. iv.

Part II
REFERENCING THE COMPONENT 1. Start the process 2. open VS .NET 3. File-> New-> Project-> visual Basic Project -> Windows Application, rename the Windows Application if required 4. Project -> Add Reference choose the com tab->Browse the encode.dll and click ok

5. Drag and Drop the following controls in the form i. 2 Label Boxes ii. 1 Text box iii. 3 Buttons 6. Include the coding in each of the Respective Button click Event. Imports encode Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox1.Text = "" End Sub Private Sub ENCRYPT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ENCRYPT.Click Dim obj As New encode.Class1 Dim temp As String temp = TextBox1.Text TextBox1.Text = obj.enco(temp) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim obj As New encode.Class1 Dim temp1 As String temp1 = TextBox1.Text TextBox1.Text = obj.deco(temp1) End Sub End Class 7. Execute the project.

You might also like