SCOUG-HELP Mailing List Archives
Return to [ 01 |
October |
2003 ]
<< Previous Message <<
>> Next Message >>
Content Type: text/plain
=====================================================
If you are responding to someone asking for help who
may not be a member of this list, be sure to use the
REPLY TO ALL feature of your email program.
=====================================================
On Wed, 1 Oct 2003 09:37:31 PDT7, Peter Skye wrote:
>What utility can decode base64 text that does _not_ have a header?
Hi, Peter -
I use a pair of REXX utilities that seem to do it just fine:
DEBASE64.CMD - - - - - - - - - - -
/* Decodes a Base64 file. */
/* */
/* Written by James L. Dean */
char_set='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
DO n=0 to 127
t.n=-1
END
DO n=0 to 63
i=C2D(SUBSTR(char_set,n+1,1))
t.i=n
END
CALL CHAROUT,'Input? '
input_file_name=LINEIN()
CALL CHAROUT,'Output? '
output_file_name=LINEIN()
SAY 'Writing "'output_file_name'".'
CALL RxFuncAdd 'SysFileDelete','RexxUtil','SysFileDelete'
i=SysFileDelete(output_file_name)
input_line=''
input_line_index=81
input_eof=0
DO WHILE (input_eof = 0)
sextet_num=1
num_bits=0
DO WHILE(sextet_num <= 4)
DO WHILE((input_eof = 0) & (input_line_index > LENGTH(input_line)))
IF LINES(input_file_name) = 0 THEN
input_eof=-1
ELSE
DO
input_line=LINEIN(input_file_name)
input_line_index=1
END
END
IF input_eof = 0 THEN
DO
i=C2D(SUBSTR(input_line,input_line_index,1))
input_line_index=input_line_index+1
t1=t.i
IF t1 >= 0 THEN
DO
sextet.sextet_num=t1
num_bits=num_bits+6
sextet_num=sextet_num+1
END
END
ELSE
DO
sextet.sextet_num=0
sextet_num=sextet_num+1
END
END
IF num_bits >= 8 THEN
DO
t1=sextet.1
t2=sextet.2
CALL CHAROUT output_file_name,D2C(4*t1+t2%16)
num_bits=num_bits-8
END
IF num_bits >= 8 THEN
DO
t1=sextet.3
CALL CHAROUT output_file_name,D2C(16*(t2//16)+(t1%4))
num_bits=num_bits-8
END
IF num_bits >= 8 THEN
DO
t2=sextet.4
CALL CHAROUT output_file_name,D2C(64*(t1//4)+t2)
END
END
ENBASE64.CMD - - - - - - - - - - -
/* Encodes a file in Base64. */
/* */
/* Written by James L. Dean */
char_set='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
CALL CHAROUT,'Input? '
input_file_name=LINEIN()
CALL CHAROUT,'Output? '
output_file_name=LINEIN()
SAY 'Writing "'output_file_name'".'
CALL RxFuncAdd 'SysFileDelete','RexxUtil','SysFileDelete'
i=SysFileDelete(output_file_name)
input_eof=0
col_num=1
DO WHILE (input_eof = 0)
num_octets=0
triple=0
DO octet_num=1 TO 3
IF input_eof = 0 THEN
DO
octet=CHARIN(input_file_name)
IF LENGTH(octet) = 0 THEN
input_eof=-1
END
IF input_eof = 0 THEN
DO
triple=256*triple+C2D(octet)
num_octets=num_octets+1
END
ELSE
triple=256*triple
END
num_sextets=(8*num_octets)%6
IF 6*num_sextets < 8*num_octets THEN
num_sextets=num_sextets+1
IF num_sextets > 0 THEN
DO
sextet_num=1
DO WHILE(sextet_num <= 4)
quotient=triple%64
stack.sextet_num=triple-64*quotient
sextet_num=sextet_num+1
triple=quotient
END
DO WHILE(num_sextets >= 1)
sextet_num=sextet_num-1
rc=CHAROUT(output_file_name,SUBSTR(char_set,1+stack.sextet_num,1))
col_num=col_num+1
IF col_num > 76 THEN
DO
rc=CHAROUT(output_file_name,D2C(13))
rc=CHAROUT(output_file_name,D2C(10))
col_num=1
END
num_sextets=num_sextets-1
END
DO WHILE(sextet_num > 1)
rc=CHAROUT(output_file_name,'=')
col_num=col_num+1
IF col_num > 76 THEN
DO
rc=CHAROUT(output_file_name,D2C(13))
rc=CHAROUT(output_file_name,D2C(10))
col_num=1
END
sextet_num=sextet_num-1
END
END
END
IF col_num > 1 THEN
DO
rc=CHAROUT(output_file_name,D2C(13))
rc=CHAROUT(output_file_name,D2C(10))
END
- - - - - - - - - - - - - - -
=====================================================
To unsubscribe from this list, send an email message
to "steward@scoug.com". In the body of the message,
put the command "unsubscribe scoug-help".
For problems, contact the list owner at
"rollin@scoug.com".
=====================================================
<< Previous Message <<
>> Next Message >>
Return to [ 01 |
October |
2003 ]
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|