Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/substitution-cipher.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / substitution-cipher.wiki` 65 lines ยท 1549 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 note key: plain letter a..z maps to the letter at the same place here 8 text key "phqgiumeaylnofdxjkrcvstzwb" 9 text msg "the quick brown fox jumps over the lazy dog, 42 times" 10 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 11 fn emit a view uchar * to void 12 o = ulong 0 13 while lt o len a bound 4096 14 k = write 1 a o sub len a o 15 if le k 0 16 exit 1 17 end 18 o = add o ulong k 19 end 20 end 21 note enc maps each lower-case letter through key; other bytes are copied 22 fn enc a view uchar * r edit uchar * to void 23 for i ulong len a 24 c = get a i 25 if and ge c 97 le c 122 26 c = get key sub c 97 27 end 28 put r i c 29 end 30 end 31 note dec builds the inverse table first, then maps through it 32 fn dec a view uchar * r edit uchar * to void 33 inv = new uchar 26 0 34 for j ulong 26 35 put inv sub get key j 97 add uchar j 97 36 end 37 for i ulong len a 38 c = get a i 39 if and ge c 97 le c 122 40 c = get inv sub c 97 41 end 42 put r i c 43 end 44 end 45 fn main to int 46 n = len msg 47 e = new uchar 256 0 48 d = new uchar 256 0 49 emit msg 50 emit nl 51 enc msg part e 0 n 52 emit part e 0 n 53 emit nl 54 dec part e 0 n part d 0 n 55 emit part d 0 n 56 emit nl 57 ret 0 58 end 59 60 {{out}} 61

62 the quick brown fox jumps over the lazy dog, 42 times

63 cei jvaql hkdtf udz yvoxr dsik cei npbw gdm, 42 caoir

64 the quick brown fox jumps over the lazy dog, 42 times

65