Openssl result does not match in cmd and windows power shell

Now I'm going to get the android debug key signature.

In the windows command (cmd.exe)

keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl.exe sha1 -binary | openssl.exe base64
Enter keystore password:  android

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore debug.keystore -destkeystore debug.keystore -deststoretype pkcs12".
uQzK/Tk81BxWs8sBwQyvTLOWCKQ=

In Windows Power Shell

keytool -exportcert -alias androiddebugkey -keystore debug.keystore | .\openssl.exe
sha1 -binary | .\openssl.exe base64
Enter keystore password:  android

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore debug.keystore -destkeystore debug.keystore -deststoretype pkcs12".
Pz8/Pwo/MDNuPyE/Pys/Pz8/Sm8K

The two results did not match.

cmd.exe: uQzK / Tk81BxWs8sBwQyvTLOWCKQ =

Power Shell: Pz8 / Pwo / MDNuPyE / Pys ​​/ Pz8 / Sm8K

Why? What happened?

+6
source share
1 answer

This is a consequence of the object pipeline in PowerShell, and you should never translate raw binary data into PowerShell because it will get corrupted.

PowerShell . PowerShell , . , .

, powershell, , . - cmd.exe powershell:

cmd /C "keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl.exe sha1 -binary | openssl.exe base64"

/ / / . , openssl.exe sha1 -in . commandhell-commandlet Start-Process, -RedirectStandardInput -RedirectStandardOutput:

keytool -exportcert -alias mykey -storepass wortwort -file f1.bin
Start-Process -FilePath openssl.exe -ArgumentList "sha1 -binary" -RedirectStandardInput f1.bin -RedirectStandardOutput f2.bin
Start-Process -FilePath openssl.exe -ArgumentList base64 -RedirectStandardInput f2.bin -RedirectStandardOutput o_with_ps.txt

keytool f1.bin. openssl.exe sha1 f1.bin f2.bin. , openssl.exe base64 f2.bin o_with-ps.txt

+4

All Articles