From bf37295faeb9535c56671f4b2050260e1b88cd32 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 15 Jan 2019 15:53:31 -0800 Subject: Updating to v6.15, which includes "external (...)" instead of separate 'externally' versions of stuff, and some auto-formatting. --- lib/base64/init.nom | 68 ++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'lib/base64') diff --git a/lib/base64/init.nom b/lib/base64/init.nom index 54f785f..a76a49f 100644 --- a/lib/base64/init.nom +++ b/lib/base64/init.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # This file defines actions for encoding/decoding base 64, as specified in: https://tools.ietf.org/html/rfc4648 @@ -15,36 +15,36 @@ test: assume (base64 $plain) == $encoded assume (base64 decode $encoded) == $plain -externally [base64 $str, base64 encode $str, $str base64] all mean: - $chars = [] - for $i in 1 to (size of $str) via 3: - $bytes = [=lua "\$str:byte(\$i, \($i + 2))"] - $chars, add $b64_chars.((($bytes.1 & 252) >> 2) + 1) - if (size of $bytes) is: - 3: - $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) - $chars, add $b64_chars.((($bytes.2 & 15) << 2) + (($bytes.3 & 192) >> 6) + 1) - $chars, add $b64_chars.(($bytes.3 & 63) + 1) - - 2: - $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) - $chars, add $b64_chars.((($bytes.2 & 15) << 2) + 1) - $chars, add "=" - - 1: - $chars, add $b64_chars.((($bytes.1 & 3) << 4) + 1) - $chars, add "=" - $chars, add "=" - return ($chars, joined) - -externally (chr $) means (=lua "string.char(\$)") -externally [decode base64 $str, $str base64 decoded, base64 decode $str] all mean: - $chars = [] - for $i in 1 to (size of $str) via 4: - $indices = [: for $j in $i to ($i + 3): add $reverse_b64.($str, character $j)] - $chars, add (chr (($indices.1 << 2) + (($indices.2 & 48) >> 4))) - if (($str, character ($i + 2)) == "="): stop - $chars, add (chr ((($indices.2 & 15) << 4) + (($indices.3 & 60) >> 2))) - if (($str, character ($i + 3)) == "="): stop - $chars, add (chr ((($indices.3 & 3) << 6) + $indices.4)) - return ($chars, joined) +external: + [base64 $str, base64 encode $str, $str base64] all mean: + $chars = [] + for $i in 1 to (size of $str) via 3: + $bytes = [=lua "\$str:byte(\$i, \($i + 2))"] + $chars, add $b64_chars.((($bytes.1 & 252) >> 2) + 1) + if (size of $bytes) is: + 3: + $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) + $chars, add $b64_chars.((($bytes.2 & 15) << 2) + (($bytes.3 & 192) >> 6) + 1) + $chars, add $b64_chars.(($bytes.3 & 63) + 1) + + 2: + $chars, add $b64_chars.((($bytes.1 & 3) << 4) + (($bytes.2 & 240) >> 4) + 1) + $chars, add $b64_chars.((($bytes.2 & 15) << 2) + 1) + $chars, add "=" + + 1: + $chars, add $b64_chars.((($bytes.1 & 3) << 4) + 1) + $chars, add "=" + $chars, add "=" + return ($chars, joined) + (chr $) means (=lua "string.char(\$)") + [decode base64 $str, $str base64 decoded, base64 decode $str] all mean: + $chars = [] + for $i in 1 to (size of $str) via 4: + $indices = [: for $j in $i to ($i + 3): add $reverse_b64.($str, character $j)] + $chars, add (chr (($indices.1 << 2) + (($indices.2 & 48) >> 4))) + if (($str, character ($i + 2)) == "="): stop + $chars, add (chr ((($indices.2 & 15) << 4) + (($indices.3 & 60) >> 2))) + if (($str, character ($i + 3)) == "="): stop + $chars, add (chr ((($indices.3 & 3) << 6) + $indices.4)) + return ($chars, joined) -- cgit v1.2.3