interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / caesar-cipher.wiki

51 lines · 1203 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7text msg "The quick brown fox Jumped over the lazy Dog"
8note emit writes every byte of a to stdout; a short write is retried, an error exits 1
9fn emit a view uchar * to void
10o = ulong 0
11while lt o len a bound 4096
12k = write 1 a o sub len a o
13if le k 0
14exit 1
15end
16o = add o ulong k
17end
18end
19note shift rotates ASCII letters by k places (0..25) into r; other bytes are copied
20fn shift a view uchar * r edit uchar * k uchar to void
21for i ulong len a
22c = get a i
23if and ge c 65 le c 90
24c = add rem add sub c 65 k 26 65
25else
26if and ge c 97 le c 122
27c = add rem add sub c 97 k 26 97
28end
29end
30put r i c
31end
32end
33fn main to int
34n = len msg
35e = new uchar 256 0
36d = new uchar 256 0
37shift msg part e 0 n 11
38emit part e 0 n
39emit nl
40note decoding is a shift by 26 - 11
41shift part e 0 n part d 0 n 15
42emit part d 0 n
43emit nl
44ret 0
45end
46</syntaxhighlight>
47{{out}}
48<pre>
49Esp bftnv mczhy qzi Ufxapo zgpc esp wlkj Ozr
50The quick brown fox Jumped over the lazy Dog
51</pre>