2013-03-19 4 views
16

GNU/Linux에서 base64 파일을 디코딩하려고하면 "base64 : invalid input"이 표시됩니다. 디코드 base64 : 유효하지 않은 입력

$ base64 test.zip | base64 -d > test2.zip 
base64: invalid input 
$ ll test* 
-rw-r--r-- 1 user grp 152 19 11:41 test.zip 
-rw-r--r-- 1 user grp 57 19 11:42 test2.zip 

나는 dos2unix 명령을 시도했지만 도움이되지 않았다.

내 64 기수 버전 :

$ base64 --version 
base64 (GNU coreutils) 5.97 
Copyright (C) 2006 Free Software Foundation, Inc. 
This is free software. You may redistribute copies of it under the terms of 
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. 
There is NO WARRANTY, to the extent permitted by law. 

Written by Simon Josefsson. 
+0

적어도 내 시스템에서는'-d'가 아니라'-D'를 해독해야합니다. 'base64 --help '는 시스템에서 무엇을 말합니까? –

+0

업그레이드를 고려하십시오. 현재 버전은 적어도 8.20 (2012 년 이후)이고 아마도 더 최근의 것입니다. –

+0

이 버전은 CentOS 5.x가 설치하는 버전이므로 환경을 제어하는 ​​사람에 따라 옵션이 없을 수도 있습니다. – Joe

답변

37

버전이 구분와 선 (기본적으로) 디코딩 할 것이다, 그러나 인코더는 기본적으로 있다고한다. (최신 버전이 문제가 없습니다.)

하나의 솔루션 :

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

대체 :

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

-i 옵션을 의미합니다 (man 페이지에서) :

-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)