Caesar cipher: Difference between revisions

1,040 bytes removed ,  5 years ago
Line 4,288:
 
</lang>
 
=={{header|Microsoft Small Basic}}==
<lang Microsoft Small Basic>
TextWindow.Write("Enter a 1-25 number key (-ve number to decode): ")
key = TextWindow.ReadNumber()
TextWindow.Write("Enter message: ")
message = text.ConvertToUpperCase(TextWindow.Read())
caeser = ""
For n = 1 To Text.GetLength(message)
letter = Text.GetSubText(message,n,1)
code = Text.GetCharacterCode(letter)
If code = 32 Then
newCode = 32
Else
newCode = code + key
If newCode > 90 Then
newCode = newCode - 26
ElseIf newCode < 65 then
newCode = newCode + 26
EndIf
EndIf
codeLetter = Text.GetCharacter(newCode)
caeser = Text.Append(caeser,codeLetter)
EndFor
TextWindow.WriteLine(message)
TextWindow.WriteLine(caeser)
</lang>
{{out}}
<pre>Enter a number key (-ve number to decode): 10
Enter message: HAVE A NICE DAY
HAVE A NICE DAY
RKFO K XSMO NKI
Press any key to continue...
 
Enter a number key (-ve number to decode): -10
Enter message: RKFO K XSMO NKI
RKFO K XSMO NKI
HAVE A NICE DAY
Press any key to continue...
</pre>
 
=={{header|SSEM}}==
Anonymous user