2

I am building an app where there is a Facebook login and registration in it, so when I need to get the key hashes using this command

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\aasal\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64


on Window10 PowerShell the following error is being given to me:

+ ... ers\aasal\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -b ...
Expressions are only allowed as the first element of a pipeline.
At line:1 char:122
+ ... asal\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary ...

Unexpected token 'sha1' in expression or statement.
At line:1 char:137
+ ... :\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64

Expressions are only allowed as the first element of a pipeline.
At line:1 char:162
+ ... :\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64

Unexpected token 'base64' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : ExpressionsMustBeFirstInPipeline

NOTE :- I downloaded OpenSSL from this link https://code.google.com/archive/p/openssl-for-windows/downloads I have the latest Java jre1.8.0_241 downloaded from oracle's website. I ran the command from different paths, C:\ , Desktop, C:\Program Files (x86)\Java, and many others and the same error kept happening.

AdnanAsali
  • 139
  • 2
  • 8

1 Answers1

1

Running the external programs without & (call) operator gives the error. Without call operator the path is just taken as an ordinary string. Try this:

& "keytool.exe" -exportcert -alias androiddebugkey -keystore "C:\Users\aasal\.android\debug.keystore" | & "C:\OpenSSL\bin\openssl.exe" sha1 -binary | & "C:\OpenSSL\bin\openssl.exe" base64

Or stop-parsing symbol (--%) can be also used:

keytool.exe --% -exportcert -alias androiddebugkey -keystore "C:\Users\aasal\.android\debug.keystore" | C:\OpenSSL\bin\openssl.exe --% sha1 -binary | C:\OpenSSL\bin\openssl.exe --% base64
Wasif
  • 14,755
  • 3
  • 14
  • 34
  • haha thanks man, I used oridnary CMD also, helped with making it the 28 characters only, powershell gave 32, – AdnanAsali Mar 25 '20 at 16:43
  • actually it does, powershell gives 32 chars for facebook hash key while cmd gives 28 chars facebook auth hash key must be 28 chars check out this thread : https://stackoverflow.com/questions/33340242/keytool-generates-32-character-long-key-hash-instead-of-28 – AdnanAsali Mar 25 '20 at 16:50