"base64: invalid input" from Linux command line base64 -d 


June 21, 2011 08:19:33    Last update: June 21, 2011 08:34:28
Got "base64: invalid input" error:
$ base64 -d base64_encoded.txt >original.bin
base64: invalid input

which can be easily dismissed as "input is invalid base64 encoded" or "partial input". But I know it's valid base64 encoded input!

The problem was, the input was base64 encoded on Windows! The error goes away after converting to Unix format with dos2unix.
dos2unix < base64_encoded.txt | base64 -d >original.bin

Version of base64 used:
$ base64 --version
base64 (GNU coreutils) 8.5
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Simon Josefsson.
Share |
| Comment  | Tags