21 lines
1.5 KiB
Plaintext
21 lines
1.5 KiB
Plaintext
Public Sub Main()
|
|
Dim byKey As Byte = 3 'The key (Enter 26 to get the same output as input)
|
|
Dim byCount As Byte 'Counter
|
|
Dim sCeasar As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ" 'Used to calculate the cipher
|
|
Dim sString As String = "The five boxing wizards jump quickly" 'Phrase to encrypt
|
|
Dim sCoded, sTemp As String 'Various strings
|
|
|
|
For byCount = 1 To Len(sString) 'Count through each letter in the phrase
|
|
If Mid(sString, byCount, 1) = " " Then 'If it's a space..
|
|
sCoded &= " " 'Keep it a space
|
|
Continue 'Jump to the next iteration of the loop
|
|
Endif
|
|
sTemp = Mid(sCeasar, InStr(sCeasar, Mid(UCase(sString), byCount, 1)) + byKey, 1) 'Get the new 'coded' letter
|
|
If Asc(Mid(sString, byCount, 1)) > 96 Then sTemp = Chr(Asc(sTemp) + 32) 'If the original was lower case then make the new 'coded' letter lower case
|
|
sCoded &= sTemp 'Add the result to the code string
|
|
Next
|
|
|
|
Print sString & gb.NewLine & sCoded 'Print the result
|
|
|
|
End
|