Advertisement
cogier

Caesar cipher

Apr 8th, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.85 KB | None | 0 0
  1. 'https://rosettacode.org/wiki/Caesar_cipher
  2. Imports System
  3. Module Program
  4.     Sub Main()
  5.         Dim byKey As Byte = 3
  6.         Dim byCount As Byte
  7.         Dim sCeasar As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
  8.         Dim sString As String = "The five boxing wizards jump quickly"
  9.         Dim sCoded As String = ""
  10.         Dim sTemp As String = ""
  11.  
  12.         For byCount = 1 To Len(sString)
  13.             If Mid(sString, byCount, 1) = " " Then
  14.                 sCoded &= " "
  15.                 Continue For
  16.             End If
  17.             sTemp = Mid(sCeasar, InStr(sCeasar, Mid(UCase(sString), byCount, 1)) + byKey, 1)
  18.             If Asc(Mid(sString, byCount, 1)) > 96 Then sTemp = Chr(Asc(sTemp) + 32)
  19.             sCoded &= sTemp
  20.         Next
  21.  
  22.         Console.WriteLine(sString & Environment.NewLine & sCoded)
  23.  
  24.     End Sub
  25. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement