Substitution cipher: Difference between revisions

Added Easylang
(added RPL)
(Added Easylang)
Line 1,054:
type of Encryption/Decryption scheme is often called a
Substitution Cipher.</pre>
 
=={{header|EasyLang}}==
<syntaxhighlight>
alpha$[] = strchars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
key$[] = strchars "VsciBjedgrzyHalvXZKtUPumGfIwJxqOCFRApnDhQWobLkESYMTN"
#
proc subst in$ . out$ a$[] b$[] .
out$ = ""
for c$ in strchars in$
for i to len a$[]
if a$[i] = c$
out$ &= b$[i]
break 1
.
.
if i > len a$[]
out$ &= c$
.
.
.
func$ enc s$ .
subst s$ r$ alpha$[] key$[]
return r$
.
func$ dec s$ .
subst s$ r$ key$[] alpha$[]
return r$
.
c$ = enc "Hello world"
print c$
print dec c$
</syntaxhighlight>
 
{{out}}
<pre>
dqnnQ YQbnx
Hello world
</pre>
 
=={{header|Factor}}==
2,046

edits