Encrypt and Decrypt

Jx_Man 2 Tallied Votes 1K Views Share

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

'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

wonderful code

mansoor480 0 Newbie Poster

lease send me another codes for mansoor480@gmail.com

mansoor480 0 Newbie Poster

please send me another codes for Email Address:mansoor480@gmail.com

Jx_Man 987 Nearly a Senior Poster Featured Poster

>> please send me another codes for Email Address:mansoor480@gmail.com

i m sorry mansoor but you must browsing this forum to get many codes here. we supplied it for free so used it with a wise.

saman sanjeewa 0 Newbie Poster

Hi,I wont to learn how i create vb program. please tell me about it. I am a student. please tell me all about it.

saman sanjeewa 0 Newbie Poster

Hi,I wont to learn how i create vb program. please tell me about it. I am a student. please tell me all about it.

Jx_Man 987 Nearly a Senior Poster Featured Poster

post your question in vb section. you can learn anything there. fell free to asked from others.

imey 0 Newbie Poster

can you help me to give several examples of inscription program especially text inscription using RC4 and WAKE's methods.
Thank you so much for your help.
Best Regards,
Meta

seo_vbnewbie 0 Newbie Poster

hi good day...thanks for your code!!!...as for now I'm looking forward to your new post.I want to ask if do you have a source code for encryption and decryption of password in database?preferably in MS ACCESS.Rignt now I'm studying your codes if I can Integrate it with my Project.......Thanks and God Bless!!!!

karlosekevin 0 Newbie Poster

Am doing a project based on ATM machine..
and i encounter a problem that inserting a card??
For that i choose to insert a floppy or cd as the password and through that the user can login to the program..
can anyone send me the codes or idea for that ??
Is this possible in VB 6

Asiya Kainat -2 Newbie Poster

Hi can i have code related to graphics and animations in vb 6.0 ....on address:asiyakainat@aol.com

Ezzaral commented: fail -2
martmarjun -2 Newbie Poster

Pls send me a code of making a wallpaper pls send the code in this email address martmarjun20@yahoo.com tnx ^_^

martmarjun -2 Newbie Poster

pls send me a code how to make a wallpaper send in this email address pls martmarjun20@yahoo.com

Ezzaral commented: fail -2
wemd22 -2 Newbie Poster

please send me the visual basic(6.0) source code for the encryption and decryption of data using Ceaser Cipher

Ezzaral commented: fail -2
MATRIX123456 -1 Newbie Poster

'in a Module' Encryption Methode by Jery MFunction Enkripsi(word As String) As StringDim temp, temp2 As IntegerDim temp3, temp4, temp5 As String' file enkriptionIf 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 IfEnd Function 'In a Form' Encryption Methode by Jery MPrivate Sub Form_Load() End Sub Private Sub Label1_Change()Dim CriptVariable As IntegerDim 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 IfEnd Sub Private Sub Text1_Change()Dim CriptVariable As IntegerDim 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 = vbNullStringEnd IfEnd Sub'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

Vega_Knight commented: dumb -1
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.