Caesar cipher: Difference between revisions

No edit summary
Line 5,684:
pack my box with five dozen liquor jugs
</pre>
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
{| class="wikitable"
! RPL Code
! Comments
|-
|
≪ → a shift
≪ '''IF''' DUP a ≥ LAST 26 + < AND
'''THEN''' a - shift + 26 MOD a + '''END'''
≫ ≫ ‘'''Rotate'''’ STO
≪ → string shift
≪ "" 1 string SIZE '''FOR''' j
string j DUP SUB NUM
65 shift '''Rotate''' 90 shift '''Rotate'''
CHR +
'''NEXT'''
≫ ''''CESAR'''' STO
|
''( m a shift -- n )''
if m in [a, a+26[
then shift it modulo 26
''( string shift -- string )''
Scan input string
extract jth ASCII code
shift if [A..Z] or [a..z]
back to character
|}
The following line of command delivers what is required:
"The quick brown fox jumped over the lazy dogs" '''CESAR'''
{{out}}
<pre>
1: "Esp bftnv mczhy qzi ufxapo zgpc esp wlkj ozrd"
</pre>
 
=={{header|Ruby}}==
<syntaxhighlight lang="ruby">class String
Line 5,698 ⟶ 5,738:
decrypted = encypted.caesar_cipher(-3)
</syntaxhighlight>
 
=={{header|Run BASIC}}==
<syntaxhighlight lang="runbasic">input "Gimme a ofset:";ofst ' set any offset you like
1,150

edits