identity-samples icon indicating copy to clipboard operation
identity-samples copied to clipboard

base64: invalid input

Open codingjeremy opened this issue 6 years ago • 1 comments

Issue by Drjacky Tuesday Jun 25, 2019 at 15:35 GMT Originally opened as https://github.com/googlesamples/android-credentials/issues/40


When I use iTerm2 terminal and work with the file, it shows:

base64: invalid input

But still generating some part of a wrong certificate in hex and generating a wrong SMS Retriever hash code as well. But when I use regular Terminal, it works well.

A sample wrong output:

➜  Desktop ./sms_retriever_hash_v9.sh --package com.example.test --keystore /path/keystore.jks

package name: com.example.test
keystore file: /path/keystore.jks

File /path/keystore.jks is found.

Enter keystore password:  password
base64: invalid input

certificate in hex: 328202c5308201ada00362010202043d1336f8300d06092a864486f70d01010b050030133111300f0603550403430853

SHA-256 output in hex: bf0ae40bf16485b2320765f3c824e263dfba8d09ec46307d6b4dd3153cfbc287

First 8 bytes encoded by base64: ywrkS/HkhbI

SMS Retriever hash code:  ywrkS/HkhbI

Machine: Mac OS 10.14.5 iTerm2 version: 3.2.9

codingjeremy avatar Sep 10 '19 20:09 codingjeremy

Comment by Drjacky Wednesday Jul 03, 2019 at 16:50 GMT


Please add --ignore-garbage to the command:

# Retrieve certificate from keystore file. Decoded with Base64 and converted to hex
cert=$(keytool -list -rfc -keystore $keystore | sed  -e '1,/BEGIN/d' | sed -e '/END/,$d' | tr -d ' \n' | base64 --decode --ignore-garbage | xxd -p | tr -d ' \n')

So it can solve the invalid input error in some terminals, like iTerm2.

https://gitlab.com/gnachman/iterm2/issues/7912

codingjeremy avatar Sep 10 '19 20:09 codingjeremy