* Generated by setuputil.sno setup.makeinclude() 04/14/2026 09:16:43
	BASE64_DL = "base64"
	LOAD("BASE64_DECODE(STRING)", BASE64_DL)
	LOAD("BASE64_ENCODE(STRING)", BASE64_DL)
**** funcs.sno:
*
* $Id: funcs.sno,v 1.2 2022-03-25 20:12:02 phil Exp $
*
* Phil Budne <phil@regressive.org>
* October 20, 2020
*
BASE64.DEFINE
**=pea
**=sect NAME
**Base 64 encoding and decoding
**=sect SYNOPSYS
**=code
**B<-INCLUDE 'base64.sno'>
**=ecode
**=sect DESCRIPTION
**=cut
**=item B<BASE64_ENCODE(>I<string>B<)>
**returns base64 encoded string.
**=item B<BASE64_DECODE(>I<base64_string>B<)>
**returns decoded string.  Ignores whitespace.
**=item B<BASE64URL_ENCODE(>I<string>B<)>
**returns base64 encoded string, replacing B<+> and B</> with B<-> and B<_>.
**=item B<BASE64URL_DECODE(>I<base64url_string>B<)>
**returns base64 decoded string.
**=cut
	DEFINE('BASE64_URL_ENCODE(S)')
	DEFINE('BASE64_URL_DECODE(S)')
							:(BASE64.END)

# https://tools.ietf.org/html/rfc4648#section-5 (pg 7)
BASE64URL_ENCODE
+	BASE64URL_ENCODE = REPLACE(BASE64_ENCODE(S), '+/', '-_')
+			:S(RETURN)F(FRETURN)

BASE64URL_DECODE
+	BASE64URL_DECODE = BASE64_DECODE(REPLACE(S, '-_', '+/'))
+			:S(RETURN)F(FRETURN)

BASE64.END
	CODE('BASE64.DEFINE')
	CODE('BASE64.END')

**=pea
**=sect COMPATIBILITY
**L<https://tools.ietf.org/html/rfc4648>
**=sect SEE ALSO
**B<snobol4>(1)
**=sect AUTHORS
**Borenstein, Freed, ISC, IBM, OpenBSD, Budne
**=cut
******** end funcs.sno
**************** end base64.sno
