This is my Cogwheel Encryption Method to encrypt and decrypt strings.

Wheel1 is Replace by Wheel2 when Encrypting and Wheel2 is Replace by wheel1 when you are decrypting...

To Encrypt a string, just call the EncryptString function

``Text2.Text = EncryptString(Text1.Text)``

To Decrypt a string, just call the DecryptString function

``Text2.Text = DecryptString(Text1.Text)``

This is my First Code Snippet so hope you like it.

commented: Nice for a first time post Jhai. +3
``````Option Explicit

Const Wheel1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#\$%^&*()_+=-{}[]:;<>,.?/"
'Replacemet For Wheel1 (Must be same with Wheel1 but make it Random)
Const Wheel2 = "89afi1jg2hbekAwxKBCFlmV=-cZrs3X#GY4.?/5tuOJ%^vyLnWzM{NP}[QR\$EIoSpq;<>,T0*()67HUdD&!@_+]:"

Public Function EncryptString(xStr As String) As String
Dim xStrHolder As String
Dim xStrIndex As Integer
Dim i As Integer
For i = 1 To Len(xStr)
xStrIndex = InStr(Wheel1, Mid(xStr, i, 1))
If xStrIndex = 0 Then
MsgBox "Invalid use of character!...", vbExclamation, "Invalid Character"
Exit Function
Else
xStrHolder = xStrHolder & Mid(Wheel2, xStrIndex, 1)
End If
Next i
EncryptString = xStrHolder
End Function

Public Function DecryptString(xStr As String) As String
Dim xStrHolder As String
Dim xStrIndex As Integer
Dim i As Integer
For i = 1 To Len(xStr)
xStrIndex = InStr(Wheel2, Mid(xStr, i, 1))
If xStrIndex = 0 Then
MsgBox "Invalid use of character!...", vbExclamation, "Invalid Character"
Exit Function
Else
xStrHolder = xStrHolder & Mid(Wheel1, xStrIndex, 1)
End If
Next i
DecryptString = xStrHolder
End Function``````

## AndreRet 362

Nice way of manipulating strings. There are some easier ways to encrypt and decrypt though. Nice code as well.