Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Caesar-cipher/Liberty-BASIC/caesar-cipher.basic
Normal file
24
Task/Caesar-cipher/Liberty-BASIC/caesar-cipher.basic
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
key = 7
|
||||
|
||||
Print "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
'Encrypt the text
|
||||
Print CaesarCypher$("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", key)
|
||||
|
||||
'Decrypt the text by changing the key to (26 - key)
|
||||
Print CaesarCypher$(CaesarCypher$("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", key), (26 - key))
|
||||
|
||||
Function CaesarCypher$(string$, key)
|
||||
If (key < 0) Or (key > 25) Then _
|
||||
CaesarCypher$ = "Key is Ouside of Bounds" : Exit Function
|
||||
For i = 1 To Len(string$)
|
||||
rotate = Asc(Mid$(string$, i, 1))
|
||||
rotate = (rotate + key)
|
||||
If Asc(Mid$(string$, i, 1)) > Asc("Z") Then
|
||||
If rotate > Asc("z") Then rotate = (Asc("a") + (rotate - Asc("z")) - 1)
|
||||
Else
|
||||
If rotate > Asc("Z") Then rotate = (Asc("A") + (rotate - Asc("Z")) - 1)
|
||||
End If
|
||||
CaesarCypher$ = (CaesarCypher$ + Chr$(rotate))
|
||||
Next i
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue