Skip to Content.
Sympa Menu

baslinux - Re: [BL] base64 (MIME) encoder/decoder

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: Lee Forrest <lforrestster AT gmail.com>
  • To: baslinux AT lists.ibiblio.org
  • Subject: Re: [BL] base64 (MIME) encoder/decoder
  • Date: Sun, 24 Dec 2006 17:01:44 -0800

On Mon, Dec 25, 2006 at 12:02:05AM +0000, sindi keesan wrote:
> I found source code base64-1.4.tar.gz (202K) which compiled perfectly with
> the compiler and glibc from SW8.1 and is at my site and also attached.

mimencode is only 9K. As far as I know it will mimencode (and
decode) anything.

>From the man page:

DESCRIPTION
The mimencode program simply converts a byte stream into
(or out of) one of the standard mail encoding formats
defined by MIME, the proposed standard for internet multi
media mail formats. Such an encoding is necessary because
binary data cannot be sent through the mail. The encod
ings understood by mimencode are preferable to the use of
the uuencode/uudecode programs, for use in mail, in sev
eral respects that were important to the authors of MIME.

By default, mimencode reads standard input, and sends a
"base64" encoded version of the input to standard output.

/quote

That app must do a lot more than mimencode.

> What got installed was only the binary and man page, so I packaged those.
>
> The 202K source code file includes a base64.pdf (160K) and a base64.exe
> (36K - for DOS?) and a b64.png file (a colored picture of the words base64
> Encode and Decode Base64 files with shadow) and the man pages in html for
> base64 and htmla nd text for rfc1341 (a standard). Should I post any of
> these or add to the package?
>
> The binary is 37K, much smaller than mutt, but too big to add to the BL3
> floppy set. Everything else I ran across used java or perl.
>
> I experimented: base64 wpce.ogg - filled the screen with ascii.

That's base64: In order to send something through the mails it has
to be ascii, not binary.

Here's the above man page excerpt in base64:

#REVTQ1JJUFRJT04KICAgICAgIFRoZSBtaW1lbmNvZGUgcHJvZ3JhbSBzaW1wbHkgY29udmVy
#dHMgYSBieXRlICBzdHJlYW0gIGludG8KICAgICAgIChvciAgb3V0ICBvZikgIG9uZSAgb2Yg
#IHRoZSBzdGFuZGFyZCBtYWlsIGVuY29kaW5nIGZvcm1hdHMKICAgICAgIGRlZmluZWQgYnkg
#TUlNRSwgdGhlIHByb3Bvc2VkIHN0YW5kYXJkIGZvciBpbnRlcm5ldCBtdWx0aQogICAgICAg
#bWVkaWEgbWFpbCBmb3JtYXRzLiAgU3VjaCBhbiBlbmNvZGluZyBpcyBuZWNlc3NhcnkgYmVj
#YXVzZQogICAgICAgYmluYXJ5IGRhdGEgY2Fubm90IGJlIHNlbnQgdGhyb3VnaCB0aGUgbWFp
#bC4gICBUaGUgIGVuY29kCiAgICAgICBpbmdzICB1bmRlcnN0b29kIGJ5IG1pbWVuY29kZSBh
#cmUgcHJlZmVyYWJsZSB0byB0aGUgdXNlIG9mCiAgICAgICB0aGUgdXVlbmNvZGUvdXVkZWNv
#ZGUgcHJvZ3JhbXMsIGZvciB1c2UgaW4gbWFpbCwgIGluICBzZXYKICAgICAgIGVyYWwgIHJl
#c3BlY3RzIHRoYXQgd2VyZSBpbXBvcnRhbnQgdG8gdGhlIGF1dGhvcnMgb2YgTUlNRS4KCiAg
#ICAgICBCeSBkZWZhdWx0LCBtaW1lbmNvZGUgcmVhZHMgc3RhbmRhcmQgaW5wdXQsICBhbmQg
#IHNlbmRzICBhCiAgICAgICAiYmFzZTY0IiAgZW5jb2RlZCB2ZXJzaW9uIG9mIHRoZSBpbnB1
#dCB0byBzdGFuZGFyZCBvdXRwdXQuCgo=

(I added the ^# to each line.)

> base64 wpce.ogg wpce.64 - produced a file 25% larger than the ogg.

The mimencoded files often (always?) are larger. Binary is more
efficient, that's why it is used when possible.

> base64 -d wpce.64 wpce2.64 - produced a file identical to wpce.ogg.
>
> -e encode and -d decode are optional
>
> Would I simply encode a binary file and then import it at the end of a
> message written with pmail/pico?

Not if you wanted the receiver's mail client to be able to deal with
it. It needs the special header and boundary markers.

Like your post here has.

> To decode an attached base64 file do I first edit a received mail to
> remove the part before the attachment (header and message body) and then
> decode that?

You'd take everything between the boundary markers, leaving them off.

> Could someone come up with simple scripts to send a prewritten message
> body and a binary attachment that has not been decoded (using pipes?) and
> to automatically decode a received message with attachment?

If you'll figure out what the headers and boundary markers have to
be, I'll write the script.

> SEND $1 $2 $3 $4
> where 1 - Subject 2 - To 3 - text message 4 - binary file to attach
>
> (I have not used pmail to download mails, forget how).
>
> or better yet, a script that deals with 1 2 and 4 but lets you write the
> message text and then send it (or put in outbox).

Neither choice is a problem.

>
> Based on pmail and base64, for those of us who don't need to authenticate
> mail separately from dialin.

It shouldn't matter what you are using to send the mail off. Just
make sure it isn't piping the mail through something to alter it
before sending.

But the headers and boundary markers have to be RFC-compliant or
your mail could end up being classified as spam or containing
a virus, and the receiver's mail client won't be able to process
the mail.

> I don't see a way to add the From (if different from the reply-to in
> .pmailrc).

That utility baffles me.

>
> It was explained that base64 encoding uses fewer and more widely used
> symbols than uuencode.

Here's the same manpage excerpt in uuencode (once again, I've added
the ^# to every line):

#begin 660 foo2
#M1$530U))4%1)3TX*("`@("`@(%1H92!M:6UE;F-O9&4@<')O9W)A;2!S:6UP
#M;'D@8V]N=F5R=',@82!B>71E("!S=')E86T@(&EN=&\*("`@("`@("AO<B`@
#M;W5T("!O9BD@(&]N92`@;V8@('1H92!S=&%N9&%R9"!M86EL(&5N8V]D:6YG
#M(&9O<FUA=',*("`@("`@(&1E9FEN960@8GD@34E-12P@=&AE('!R;W!O<V5D
#M('-T86YD87)D(&9O<B!I;G1E<FYE="!M=6QT:0H@("`@("`@;65D:6$@;6%I
#M;"!F;W)M871S+B`@4W5C:"!A;B!E;F-O9&EN9R!I<R!N96-E<W-A<GD@8F5C
#M875S90H@("`@("`@8FEN87)Y(&1A=&$@8V%N;F]T(&)E('-E;G0@=&AR;W5G
#M:"!T:&4@;6%I;"X@("!4:&4@(&5N8V]D"B`@("`@("!I;F=S("!U;F1E<G-T
#M;V]D(&)Y(&UI;65N8V]D92!A<F4@<')E9F5R86)L92!T;R!T:&4@=7-E(&]F
#M"B`@("`@("!T:&4@=75E;F-O9&4O=75D96-O9&4@<')O9W)A;7,L(&9O<B!U
#M<V4@:6X@;6%I;"P@(&EN("!S978*("`@("`@(&5R86P@(')E<W!E8W1S('1H
#M870@=V5R92!I;7!O<G1A;G0@=&\@=&AE(&%U=&AO<G,@;V8@34E-12X*"B`@
#M("`@("!">2!D969A=6QT+"!M:6UE;F-O9&4@<F5A9',@<W1A;F1A<F0@:6YP
#M=70L("!A;F0@('-E;F1S("!A"B`@("`@("`B8F%S938T(B`@96YC;V1E9"!V
#I97)S:6]N(&]F('1H92!I;G!U="!T;R!S=&%N9&%R9"!O=71P=70N"@H`
#`
#
#end

Lee

--
Basic Linux: Small is Beautiful
http://www.basiclinux.com.ru





Archive powered by MHonArc 2.6.24.

Top of Page