Version 18 of Base 64 encode/decode

Updated 2002-06-25 18:13:27

The following applications invoke the tcllib base64 encoding/decoding package.

They are intended to be a pair of applications allowing the user to encode an arbitrary file or data presented on standard input, or decode an encoded file or data .

 #! /usr/tcl84/bin/tclsh
 package require base64
 # Purpose: read stdin or a file on the argument line and output to stdout
 #      a base64 encoding of the file.

 if { $argc > 0 } {
        set fin [open [lindex $argv 1] "r"]
 } else {
        set fin stdin
 }
 while { ! [feof $fin] } {
        set input [read $fin 1024]
        puts [::base64::encode $input]
 }
 close $fin

 #! /usr/tcl84/bin/tclsh
 package require base64
 # Purpose: read stdin or a file on the argument line and output to stdout
 #      a base64 decoding of the file.

 if { $argc > 0 } {
        set fin [open [lindex $argv 1] "r"]
 } else {
        set fin stdin
 }
 while { ! [feof $fin] } {
        set input [read $fin 1024]
        puts [::base64::decode $input]
 }
 close $fin

Category Application