Adblock breaks this site

Substitution cipher in VB6

Discussion in 'Programming General' started by kandymann12, Jun 28, 2008.

  1. kandymann12

    kandymann12 Forum Addict

    Joined:
    Mar 8, 2007
    Posts:
    456
    Referrals:
    1
    Sythe Gold:
    0
    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:

    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.
     
  2. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    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 Stat Checker. | New RsBot RuneTool 1st Release >


 
 
Adblock breaks this site