[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: base64 terminal input failure
From: |
Bob Proulx |
Subject: |
Re: base64 terminal input failure |
Date: |
Thu, 16 Jun 2011 18:19:04 -0600 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
e-letter wrote:
> I have tried to copy base64 encoded text from the clipboard (i.e. a
> web mail message) to the command terminal:
>
> base64 -d 'xyz'
>
> where 'xyz' is the base64 text. According to the manual, standard
> input can be accepted if a file is not accepted but instead the
> terminal response is:
>
> base64: xyz: No such file or directory
>
> What is my mistake please?
The base64 syntax is:
base64 [OPTION]... [FILE]
You have specified one option and what appears to the command to be
one file. The -d fits in the [OPTION] spot and the xyz fits in the
[FILE] spot.
The brackets indicate that those parts are optional. For [OPTIONS] no
options means to encode. Specifying -d means to decode.
For [FILE] this means that if a file is specified then the command
will open the file and read it. If no file is specified on the
command line then it will read standard input.
> The command:
> 'echo xyz | base64 -d'
>
> returns:
> �,base64: invalid input
>
> If the base64 text is saved as a file, conversion is successful.
This is because "xyz" isn't valid base64 encoded data. It works
successfully if you give it valid input data instead of random
characters. See this example:
$ echo foo | base64
Zm9vCg==
$ echo foo | base64 | base64 -d
foo
$ echo Zm9vCg== | base64 -d
foo
As you can see if the input is valid then it will decode it correctly.
Bob