Marked as: Advanced
Hello,
It's possible to encode applications in base64 format so that they appear as characters. That feature make it possible to include the code in rexx and create a self extracting installers or just extract binary code from external files.
Example of where it's used:
PMMail and other mail software use base64 to encode attached files
ClipArt packages
etc.
If you look in rexx Tips & Tricks you'll notice code that describe how to decode base64 encoded data, though I think it may contain some missing pieces that I've adjusted somewhat.
Here's an example you may want to try ( based on code from Rexx Tips & Tricks ).
DeCodeB64: procedure expose x_range. clp.
input_data = translate( ARG(1), '0000'x, '0d0a'x )
l64 = length( input_data )
if l64 = 0 then
Return -1 /* Nothing to extract */
retval = x2b( c2x( translate( input_data, x_range.d_code, x_range.s_code ) ) )
t64 = length( retval )
drop f_data
f_data = ''
do while retval \= ''
parse var retval +2 bin.0 +6 +2 bin.1 +6 +2 bin.2 +6 +2 bin.3 +6 +2 bin.4 +6 +2 bin.5 +6 +2 bin.6 +6 +2 bin.7 +6 +2 bin.8 +6 +2 bin.9 +6 +2 bin.10 +6 +2 bin.11 +6 retval
f_data = f_data || bin.0 || bin.1 || bin.2 || bin.3 || bin.4 || bin.5 || bin.6 || bin.7 || bin.8 || bin.9 || bin.10 || bin.11
end
input_data = x2c( b2x( left( f_data, length( f_data ) % 8 * 8 ) ) )
Return input_data