Monday, May 28, 2012

Fungsi Encrypt Dan Decrypt Sederhana

Option Explicit 

Public Function
Encrypt(sText As String) As String
Dim i As Integer
Dim
msg As String
For i =
1 To Len(sText)
msg = msg & Chr(Asc(Mid(sText, i, 1)) + 9)
Next
Encrypt = msg
End Function

Public Function
Decrypt(sText As String) As String
Dim i As Integer
Dim
msg As String
For i =
1 To Len(sText)
msg = msg & Chr(Asc(Mid(sText, i, 1)) - 9)
Next
Decrypt = msg
End Function
Contoh penggunaan fungsi encrypt dan decrypt sederhana
Private Sub Command1_Click() 
Text2.Text = Encrypt(Text1.Text)
End Sub

Private Sub
Command2_Click()
Text3.Text = Decrypt(Text2.Text)
End Sub