Sta*_*Man 6 windows powershell android cmd
现在我要获得android调试密钥的签名.
在Windows命令(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=
Run Code Online (Sandbox Code Playgroud)
在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
Run Code Online (Sandbox Code Playgroud)
两个结果不匹配.
cmd.exe:uQzK/Tk81BxWs8sBwQyvTLOWCKQ =
Power Shell:Pz8/Pwo/MDNuPyE/Pys/Pz8/Sm8K
为什么?发生了什么?
这是 PowerShell 中对象管道的结果,您永远不应该在 PowerShell 中管道原始二进制数据,因为它会被损坏。
在 PowerShell 中传输原始二进制数据永远不安全。PowerShell 中的管道用于可以安全地自动转换为字符串数组的对象和文本。请阅读本文以获取完整的解释和详细信息。
用powershell计算的结果是错误的,因为你使用了管道。解决此问题的一种方法是在 powershell 中使用 cmd.exe:
cmd /C "keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl.exe sha1 -binary | openssl.exe base64"
Run Code Online (Sandbox Code Playgroud)
您可以使用管道来从文件读取/写入输入/输出。不幸的是 openssl.exe sha1 没有-in指定输入文件的参数。因此我们需要使用 powershell-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
Run Code Online (Sandbox Code Playgroud)
keytool写入文件f1.bin. 然后openssl.exe sha1读取f1.bin并写入f2.bin。最后,openssl.exe base64读取f2.bin和写入o_with-ps.txt
| 归档时间: |
|
| 查看次数: |
529 次 |
| 最近记录: |