Re: decoding MIME:Base64 question?

From: Wiggins D Anconia (wiggins_at_danconia.org)
Date: 01/13/04

  • Next message: William Ampeh: "Re: Using Getopt::Std"
    Date: Tue, 13 Jan 2004 12:31:01 -0700
    To: "Tino Arellano" <nurbs@linuxmail.org>, beginners@perl.org
    
    

    >
    > Hello folks,
    >
    > If I encode a file with MIME::Base64 with the following script,
    encode_base64.pl. The question is; how do I decode
    > the file? I use the following script, decode_base64.pl to decode back
    to the original source but that did not work because
    > they are different from each other.
    >
    > Thank you...
    >

    Naturally you should use strict and warnings...

    To get your code snippets to work for me I needed to 'binmode' the read
    handle in the first script, 'binmode' the output handle in the second,
    and read a line at a time rather than chunks in the second. The binmode
    may be system or file dependent I am not clear about this. In the case
    of the base64 encoded data there is no need to read it chunked like that
    I suspect the newlines are being included in $buf which is being base64
    decoded and included as data rather than being removed as they would
    when the record separator is allowed to do its thing, though this isn't
    clear to me either since it should drop them or skip them or something
    since newlines aren't in the base64 character set. You might try
    enabling the diagnostic messages and see what they provide...

    <snip code>

    perldoc -f binmode

    http://danconia.org


  • Next message: William Ampeh: "Re: Using Getopt::Std"

    Relevant Pages

    • Re: Decoding Base64
      ... i am trying to decode a block of base64 into text, ... Richard Heathfield ... I've no idea what Richard has said else where, but his attitude to your posting here is hardly surprising. ... What do you think your local computer store would tell you if you took a printout of that code in and asked how to decode it? ...
      (comp.lang.c)
    • Re: A little UNIX scripting challenge...
      ... extend this script to decode the data a little further. ... With the output you generated with your script, ... Nikki ... > I am a UNIX novice but I'd like to write a script to decode some ...
      (comp.unix.tru64)
    • Re: Base64
      ... | pass a base64 encoded string into and get back a decoded String. ... ** encodeencodes an arbitrary data block into MIME Base64 format string ... int encode(unsigned s_len, char *src, unsigned d_len, char *dst) ... ** DECODE BASE64 into RAW ...
      (comp.lang.c)
    • Re: Integer data type -> binary coded decimal
      ... While it doesn't answer your specific question, here is a routine to ... decode base64 data. ... It will decode the data into separate 3-byte pieces ... the end of the base64 string. ...
      (microsoft.public.sqlserver.programming)
    • Re: Decoding Base64
      ... Richard Heathfield wrote: ... i am trying to decode a block of base64 into text, ... if i knew how it was encoded, i'd know how to decode it. ... i know nothing about this sort of computer speak. ...
      (comp.lang.c)