decode base64: invalid input

前端 未结 4 568
执念已碎
执念已碎 2021-02-01 13:37

Trying to decode base64 file on GNU/Linux, I get \"base64: invalid input\".

$ base64 test.zip | base64 -d > test2.zip
base64: invalid input
$ ll test*
-rw-r--         


        
4条回答
  •  醉梦人生
    2021-02-01 14:03

    That version will not decode (by default) lines with separators, yet the encoder does that by default. (Newer versions don't have this problem.)

    One solution:

    base64 -w 0 foo.zip | base64 -d > foo2.zip

    Alternate:

    base64 foo.zip | base64 -di > foo2.zip

    The -i option stands for (from the man page):

    -i, --ignore-garbage
           When decoding, ignore non-alphabet characters.
    [...]
    Decoding require compliant input by default, use --ignore-garbage to
    attempt to recover from non-alphabet characters (such as newlines)
    

提交回复
热议问题