Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
36
Task/Caesar-cipher/GFA-Basic/caesar-cipher.basic
Normal file
36
Task/Caesar-cipher/GFA-Basic/caesar-cipher.basic
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
'
|
||||
' Caesar cypher
|
||||
'
|
||||
OPENW 1 ! Creates a window for handling input/output
|
||||
CLEARW 1
|
||||
INPUT "string to encrypt ";text$
|
||||
INPUT "encryption key ";key%
|
||||
encrypted$=@encrypt$(UPPER$(text$),key%)
|
||||
PRINT "Encrypted: ";encrypted$
|
||||
PRINT "Decrypted: ";@decrypt$(encrypted$,key%)
|
||||
'
|
||||
PRINT "(Press any key to end program.)"
|
||||
~INP(2)
|
||||
CLOSEW 1
|
||||
'
|
||||
FUNCTION encrypt$(text$,key%)
|
||||
LOCAL result$,i%,c%
|
||||
result$=""
|
||||
FOR i%=1 TO LEN(text$)
|
||||
c%=ASC(MID$(text$,i%))
|
||||
IF c%<ASC("A") OR c%>ASC("Z") ! don't encrypt non A-Z
|
||||
result$=result$+CHR$(c%)
|
||||
ELSE
|
||||
c%=c%+key%
|
||||
IF c%>ASC("Z")
|
||||
c%=c%-26
|
||||
ENDIF
|
||||
result$=result$+CHR$(c%)
|
||||
ENDIF
|
||||
NEXT i%
|
||||
RETURN result$
|
||||
ENDFUNC
|
||||
'
|
||||
FUNCTION decrypt$(text$,key%)
|
||||
RETURN @encrypt$(text$,26-key%)
|
||||
ENDFUNC
|
||||
Loading…
Add table
Add a link
Reference in a new issue