I'm using a version of signapk for one of my projects. I sign my apk with a public, private key pair (.pk8 & .pem).
My application uses the facebook single sign on mechanism and I need a hash of the signing certificate registered with facebook to ensure that the correct app is starting the single sign on process. Facebook gives the following example code for generating this hash:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore
| openssl sha1 -binary
| openssl base64
I'm a little bit confused on how to generate the appropriate hash from my public key, private key pair that I use for signing.
This method works for you APK signed with your PK8 + PEM key pair. Or with any other (correctly) signed APK
Certificate could be known from *.apk file
execute:
keytool -printcert -file CERT.RSA
Check sha1 bytes
the bytes at sha1 fingerprint signature are needed to write to sha1.bin (you can use an hexadecimal editor)
just execute:
openssl base64 -in sha1.bin -out base64.txt
so, base64.txt contains the APK's FB KeyHash
Facebook hash is actually the base64 encoding of SHA1.
So you have to generate sha1 from your certificate file that ends with .pem extension!..
Command to get SHA1 from a .pem file:- openssl x509 -fingerprint -in certificate.pem -noout
this command will return SHA1 of your .pem file, replace certicicate.pem with the name of your .pem file!...
After succesfully getting the SHA1 Now your task is to encode the SHA1 into base64 and there are alot of ways to do that, i recommend this website:
http://tomeko.net/online_tools/hex_to_base64.php?lang=en
go to this site write your SHA1 and in the last textbox you will received the encoded base64 that is the HASH for your facebook developer app!..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With