Encryption Methode


'in a Module
' Encryption Methode 
Function Enkripsi(word As String) As String
Dim temp, temp2 As Integer
Dim temp3, temp4, temp5 As String
' file enkription
If Len(word > 0) Then
    ReDim CharacterValue(Len(word) - 1) As Byte
    For i = 0 To (Len(word) - 1)
    temp = Asc(Mid(word, i + 1, 1)) + 77
    If (temp > 255) Then temp = temp - 255
    CharacterValue(i) = CByte(temp)
    Next i

End If
End Function

'In a Form
' Encryption Methode by Jery M
Private Sub Form_Load()

End Sub

Private Sub Label1_Change()
Dim CriptVariable As Integer
Dim StringBuffer As String

If Len(Label1.Caption) > 0 Then
    'change data from label1 back to ke label3
    ReDim CharacterValue(Len(Label1.Caption) - 1) As Byte
    For i = 0 To (Len(Label1.Caption) - 1)
    CriptVariable = Asc(Mid(Label1.Caption, i + 1, 1)) - 77
    If CriptVariable < 0 Then CriptVariable = CriptVariable + 255
    CharacterValue(i) = CByte(CriptVariable)
    Next i
    'show it in label3
    StringBuffer = vbNullString
    For i = 0 To (Len(Label1.Caption) - 1)
    StringBuffer = StringBuffer & Chr(CharacterValue(i))
    Next i
    Label3.Caption = StringBuffer

Else
    MsgBox "empty"
End If
End Sub

Private Sub Text1_Change()
Dim CriptVariable As Integer
Dim StringBuffer As String
'Ambil data yang akan dan dienkripsi

If Len(Text1.Text) > 0 Then
    ReDim CharacterValue(Len(Text1.Text) - 1) As Byte
    For i = 0 To (Len(Text1.Text) - 1)
    CriptVariable = Asc(Mid(Text1.Text, i + 1, 1)) + 77
    If (CriptVariable > 255) Then CriptVariable = CriptVariable - 255
    CharacterValue(i) = CByte(CriptVariable)
    Next i
    'show encryption in label1
    StringBuffer = vbNullString
    For i = 0 To (Len(Text1.Text) - 1)
    StringBuffer = StringBuffer & Chr(CharacterValue(i))
    Next i
    Label1.Caption = StringBuffer
   Else
    Label1.Caption = vbNullString
End If
End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s