This is code for Encrypt and Decrypt. this a simple logic of encryption. Please leave comment or feedback if this code helps you. Thanks. Jery. :)
the encrypt function place in a module.
This Code needed :
1 Module
1 combo box (For input before encryption) text1 in this program
2 label (For encryption result and encryption reading) --> label1 and label 3 in this program
Encrypt and Decrypt
'in a Module
' Encryption Methode by Jery M
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
Estella 23 Junior Poster in Training
mansoor480 0 Newbie Poster
mansoor480 0 Newbie Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster
saman sanjeewa 0 Newbie Poster
saman sanjeewa 0 Newbie Poster
Jx_Man 987 Nearly a Senior Poster Featured Poster
imey 0 Newbie Poster
seo_vbnewbie 0 Newbie Poster
karlosekevin 0 Newbie Poster
martmarjun -2 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.