Caesar cipher: Difference between revisions
Content added Content deleted
Walterpachl (talk | contribs) (→{{header|REXX}}: Refurbished (variable names)) |
imported>Arakov |
||
Line 2,745: | Line 2,745: | ||
Decoded string: "HELLO! THIS IS A SECRET MESSAGE!"</pre> |
Decoded string: "HELLO! THIS IS A SECRET MESSAGE!"</pre> |
||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA |
ELENA 6.x : |
||
<syntaxhighlight lang="elena">import system'routines; |
<syntaxhighlight lang="elena">import system'routines; |
||
import system'math; |
import system'math; |
||
Line 2,758: | Line 2,758: | ||
class Encrypting : Enumerator |
class Encrypting : Enumerator |
||
{ |
{ |
||
int |
int _key; |
||
Enumerator |
Enumerator _enumerator; |
||
constructor(int key, string text) |
constructor(int key, string text) |
||
{ |
{ |
||
_key := key; |
|||
_enumerator := text.enumerator(); |
|||
} |
} |
||
bool next() => |
bool next() => _enumerator; |
||
reset() => |
reset() => _enumerator; |
||
enumerable() => |
enumerable() => _enumerator; |
||
get() |
get Value() |
||
{ |
{ |
||
var ch := |
var ch := *_enumerator; |
||
var index := Letters.indexOf(0, ch); |
var index := Letters.indexOf(0, ch); |
||
Line 2,781: | Line 2,781: | ||
if (-1 < index) |
if (-1 < index) |
||
{ |
{ |
||
^ Letters[( |
^ Letters[(_key+index).mod:26] |
||
} |
} |
||
else |
else |
||
Line 2,788: | Line 2,788: | ||
if (-1 < index) |
if (-1 < index) |
||
{ |
{ |
||
^ BigLetters[( |
^ BigLetters[(_key+index).mod:26] |
||
} |
} |
||
else |
else |
||
Line 2,827: | Line 2,827: | ||
Decrypted text:Pack my box with five dozen liquor jugs. |
Decrypted text:Pack my box with five dozen liquor jugs. |
||
</pre> |
</pre> |
||
=={{header|Elixir}}== |
=={{header|Elixir}}== |
||
<syntaxhighlight lang="elixir">defmodule Caesar_cipher do |
<syntaxhighlight lang="elixir">defmodule Caesar_cipher do |