Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Vigen-re-cipher/11l/vigen-re-cipher.11l
Normal file
28
Task/Vigen-re-cipher/11l/vigen-re-cipher.11l
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
F encrypt(key, text)
|
||||
V out = ‘’
|
||||
V j = 0
|
||||
L(c) text
|
||||
I !c.is_alpha()
|
||||
L.continue
|
||||
out ‘’= Char(code' (c.uppercase().code + key[j].code - 2 * ‘A’.code) % 26 + ‘A’.code)
|
||||
j = (j + 1) % key.len
|
||||
R out
|
||||
|
||||
F decrypt(key, text)
|
||||
V out = ‘’
|
||||
V j = 0
|
||||
L(c) text
|
||||
I !c.is_alpha()
|
||||
L.continue
|
||||
out ‘’= Char(code' (c.code - key[j].code + 26) % 26 + ‘A’.code)
|
||||
j = (j + 1) % key.len
|
||||
R out
|
||||
|
||||
V key = ‘VIGENERECIPHER’
|
||||
V original = ‘Beware the Jabberwock, my son! The jaws that bite, the claws that catch!’
|
||||
V encrypted = encrypt(key, original)
|
||||
V decrypted = decrypt(key, encrypted)
|
||||
|
||||
print(original)
|
||||
print(‘Encrypted: ’encrypted)
|
||||
print(‘Decrypted: ’decrypted)
|
||||
Loading…
Add table
Add a link
Reference in a new issue