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/base64-encode-data.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 / base64-encode-data.wiki` 71 lines ยท 1649 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 text abc "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 8 text m0 "M" 9 text m1 "Ma" 10 text m2 "Man" 11 text m3 "Hello, World!" 12 text m4 "To err is human, but to really foul things up you need a computer.\n -- Paul R. Ehrlich" 13 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 14 fn emit a view uchar * to void 15 o = ulong 0 16 while lt o len a bound 4096 17 k = write 1 a o sub len a o 18 if le k 0 19 exit 1 20 end 21 o = add o ulong k 22 end 23 end 24 note b64 takes the input 3 bytes (24 bits) at a time and writes 4 alphabet characters, '=' padding 25 note a short last group; output up to 512 bytes (input up to 384, longer traps 3) 26 fn b64 a view uchar * to void 27 o = new uchar 512 0 28 p = ulong 0 29 i = ulong 0 30 while lt i len a bound 200 31 r = sub len a i 32 v = shl ulong get a i 16 33 if gt r 1 34 v = or v shl ulong get a add i 1 8 35 end 36 if gt r 2 37 v = or v ulong get a add i 2 38 end 39 put o p get abc shr v 18 40 put o add p 1 get abc and shr v 12 63 41 put o add p 2 61 42 put o add p 3 61 43 if gt r 1 44 put o add p 2 get abc and shr v 6 63 45 end 46 if gt r 2 47 put o add p 3 get abc and v 63 48 end 49 p = add p 4 50 i = add i 3 51 end 52 emit part o 0 p 53 emit nl 54 end 55 fn main to int 56 b64 m0 57 b64 m1 58 b64 m2 59 b64 m3 60 b64 m4 61 ret 0 62 end 63 64 {{out}} 65

66 TQ==

67 TWE=

68 TWFu

69 SGVsbG8sIFdvcmxkIQ==

70 VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=

71