Updating everyone on the status of my request for Base64 Encoding and Decoding.
Luis suggested a utility on Windows that I could use called certutil. I researched and found in fact that I could. The syntax is as follows:
Code: Select all
00450 If WBPLATFORM$="WINDOWS" Then Execute "sys -m certutil -decode encoded.fil decoded.fil"
This would decode a file containing data that had been encoded base64. This works on windows.
On the Mac I found a similar utility:
Code: Select all
00470 ! If WBPLATFORM$="MAC" Then Execute "sys -m openssl -d -in encoded.fil -out decoded.fil"
Both utilities seem to work just fine. But I was not satisfied with having to make a shell call anytime I wanted to encode or decode a dataset. So I started doing some research and found this Wikipedia page that described what was required to roll your own. So that I did.
https://en.wikipedia.org/wiki/Base64
I created a library that contains FN_ENCODEDBASE64(CONTENT$) & FN_DECODEBASE64(CONTENT$) Both functions use a pointer to CONTENT$ so the result is returned in place of the what was sent. CONTENT$ is limited to 1,200,000 characters and you will need to make sure your workstack can accommodate a string of that size. It can handle any characters is the ASCII character set from 0 to 255.
Just load the library in your calling program Then use one of the functions. Here is an example of Encoding some simple text:
Code: Select all
00010 Library Release,"\macprg\base64_l": FN_ENCODEBASE64,FN_DECODEBASE64
00030 DIM CT$*1200000
00050 LET CT$="Man"
00070 LET FN_ENCODEBASE64(CT$)
00090 PRINT CT$
Your output from this should be: TWFu
This is one of the examples on the Wikipedia Page. You can read through that to see how the encoding is done.
Please test in your environment and don't hesitate to give me feedback if you find any issues!
I have attached the source code to this post. You will need to rename the extension to .wbs or .brs to use