2018-08-30 00:57:22 +03:00
|
|
|
/+ base64, *test
|
2018-08-29 03:03:34 +03:00
|
|
|
:: XX move to zuse
|
|
|
|
::
|
|
|
|
|%
|
|
|
|
++ octn
|
|
|
|
|%
|
|
|
|
++ en |=(a=@u `octs`[(met 3 a) (swp 3 a)])
|
|
|
|
++ de |=(a=octs `@u`(rev 3 p.a q.a))
|
|
|
|
--
|
|
|
|
++ en-base64url
|
|
|
|
~(en base64 | &)
|
|
|
|
++ de-base64url
|
|
|
|
~(de base64 | &)
|
|
|
|
--
|
|
|
|
::
|
2018-08-30 00:57:22 +03:00
|
|
|
|%
|
2018-08-29 03:03:34 +03:00
|
|
|
++ test-base64
|
|
|
|
;: weld
|
2018-08-29 21:09:37 +03:00
|
|
|
%+ expect-eq
|
2018-08-29 20:58:49 +03:00
|
|
|
!> 'AQAB'
|
|
|
|
!> (en-base64url (en:octn 65.537))
|
|
|
|
::
|
2018-08-29 21:09:37 +03:00
|
|
|
%+ expect-eq
|
2018-08-29 20:58:49 +03:00
|
|
|
!> 65.537
|
|
|
|
!> (de:octn (need (de-base64url 'AQAB')))
|
|
|
|
::
|
2018-08-29 03:03:34 +03:00
|
|
|
:: echo "hello" | base64
|
2018-08-29 21:09:37 +03:00
|
|
|
%+ expect-eq
|
2018-08-29 20:58:49 +03:00
|
|
|
!> 'aGVsbG8K'
|
|
|
|
!> (en:base64 (as-octs:mimes:html 'hello\0a'))
|
|
|
|
::
|
2018-08-29 21:09:37 +03:00
|
|
|
%+ expect-eq
|
2018-08-29 20:58:49 +03:00
|
|
|
!> 'hello\0a'
|
|
|
|
!> +:(need (de:base64 'aGVsbG8K'))
|
|
|
|
::
|
2018-08-29 03:03:34 +03:00
|
|
|
:: echo -n -e "\x01\x01\x02\x03" | base64
|
2018-08-29 21:09:37 +03:00
|
|
|
%+ expect-eq
|
2018-08-29 20:58:49 +03:00
|
|
|
!> 'AQECAw=='
|
|
|
|
!> (en:base64 (en:octn 0x101.0203))
|
|
|
|
::
|
2018-08-29 21:09:37 +03:00
|
|
|
%+ expect-eq
|
2018-08-29 20:58:49 +03:00
|
|
|
!> `@t`0x302.0101
|
|
|
|
!> +:(need (de:base64 'AQECAw=='))
|
2018-08-29 03:03:34 +03:00
|
|
|
==
|
|
|
|
--
|
|
|
|
|