• Log in or sign up for an account here: https://www.sythe.org/login

Substitution cipher in VB6

kandymann12

Forum Addict
Joined
Mar 8, 2007
Sythe Gold
0
Messages
456
Location
San Diego, California boot camp.
Substitution cipher in VB6
How would I make one? If what the plan was for it to have 2 text boxes. One having a number, which will be how many numbers to shift to the right; So example would be if the number was 10, it would be something like this:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
QRSTUVWXYZABCDEFGHIJKLMNOP

So in essence, the cipher would shift 10 letters to the right. And when it has done that, replace the unencrypted message with the unencrypted one. And do spaces count as a character? Because I was thinking of looking at the code if anyone helps me, and make a different one so that it wouldn't cipher the first and last letters of the words in the message.
 
Substitution cipher in VB6
This will encrypt it 10 Letters to the right.
So it will make:
Code:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
turn into:
Code:
KLMNOPQRSTUVWXYZABCDEFGHIJ

If the character is not part of the Alphabet it won't that character.

I didn't include the Decrypt function mainly because i couldn't be bothered reversing that effect, you should be able to do it yourself by studying that code.

To use it simply do this:
Code:
Msgbox Encrypt("Hi would you like some pie?")

Source:
Code:
Public Function Encrypt(strWord As String) As String
    Dim intCount As Integer
    Dim strEncrypted As String
    Dim intChar As Integer
    Dim IntNum As Integer
    For intCount = 1 To Len(strWord)
        intChar = Asc(Mid(strWord, intCount, 1))
        If intChar > 96 And intChar < 123 Then
            If intChar < 113 Then
                strEncrypted = strEncrypted & Chr$(intChar + 10)
            Else
                IntNum = 122 - intChar
                IntNum = 10 - IntNum
                IntNum = 96 + IntNum
                strEncrypted = strEncrypted & Chr$(IntNum)
            End If
        ElseIf intChar > 64 And intChar < 91 Then
            If intChar < 81 Then
                strEncrypted = strEncrypted & Chr$(intChar + 10)
            Else
                IntNum = 90 - intChar
                IntNum = 10 - IntNum
                IntNum = 64 + IntNum
                strEncrypted = strEncrypted & Chr$(IntNum)
            End If
        Else
            strEncrypted = strEncrypted & Mid(strWord, intCount, 1)
        End If
    Next intCount
    Encrypt = strEncrypted
End Function
 
Runescape Gamblingrunescape gambling
Back
Top