Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Caesar-cipher/Logo/caesar-cipher.logo
Normal file
34
Task/Caesar-cipher/Logo/caesar-cipher.logo
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
; some useful constants
|
||||
make "lower_a ascii "a
|
||||
make "lower_z ascii "z
|
||||
make "upper_a ascii "A
|
||||
make "upper_z ascii "Z
|
||||
|
||||
; encipher a single character
|
||||
to encipher_char :char :key
|
||||
local "code make "code ascii :char
|
||||
local "base make "base 0
|
||||
ifelse [and (:code >= :lower_a) (:code <= :lower_z)] [make "base :lower_a] [
|
||||
if [and (:code >= :upper_a) (:code <= :upper_z)] [make "base :upper_a] ]
|
||||
ifelse [:base > 0] [
|
||||
output char (:base + (modulo ( :code - :base + :key ) 26 ))
|
||||
] [
|
||||
output :char
|
||||
]
|
||||
end
|
||||
|
||||
; encipher a whole string
|
||||
to caesar_cipher :string :key
|
||||
output map [encipher_char ? :key] :string
|
||||
end
|
||||
|
||||
; Demo
|
||||
make "plaintext "|The five boxing wizards jump quickly|
|
||||
make "key 3
|
||||
make "ciphertext caesar_cipher :plaintext :key
|
||||
make "recovered caesar_cipher :ciphertext -:key
|
||||
|
||||
print sentence "| Original:| :plaintext
|
||||
print sentence "|Encrypted:| :ciphertext
|
||||
print sentence "|Recovered:| :recovered
|
||||
bye
|
||||
Loading…
Add table
Add a link
Reference in a new issue