Android - getting a hash key for integration with Facebook

I am trying to implement Facebook in my application in order to allow things like sending stuff to the user's wall, status update, etc.

So, after downloading the material, I was told to get the key using the keystore file. I decided to be brave and create my own keystore file (for publication later) and did it successfully.

After creating the file, although I have all kinds of problems trying to extract the key from it, I entered the command through the keytool / command prompt and asked me for a password to store the keys ...

After entering the password that I set first, I get nothing but strange characters and letters ascii, as well as the data in my keystore in the middle. What is going wrong?

UPDATE: Well, I know that you may need to use OpenSSL to display the text correctly. I installed OpenSSL, but how to use it to get the hash code?

+3
source share
4 answers
  • Download Openssl from: http://code.google.com/p/openssl-for-windows/downloads/list

  • Make openssl folder on C drive

  • Extract zip files to openssl folder

  • make sure the directory where the keytool executable is located is in your path. (For example, on my Windows 7 computer, it is located in the folder C: \ Program Files (x86) \ Java \ jre6 \ bin.)
  • open cmd and paste:

    keytool -exportcert -alias androiddebugkey -keystore ~ ​​/.android/debug.keystore | C: \ openssl \ bin \ openssl sha1 -binary | C: \ openssl \ bin \ openssl base64

Android -

+4

Linux, :

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore > key.out
cat key.out | openssl sha1 -binary > key.bin
cat key.bin | openssl base64

, , Facebook-. , , facebook.

+3

.

* try {       PackageInfo info = getPackageManager(). GetPackageInfo (                " ",               PackageManager.GET_SIGNATURES);        ( : info.signatures) {           MessageDigest md = MessageDigest.getInstance( "SHA" );           md.update(signature.toByteArray());           Log.d( " ", Base64.encodeToString(md.digest(), Base64.DEFAULT));           }   } catch (NameNotFoundException e) {} catch (NoSuchAlgorithmException e) { } *

opensl .

0

, Hash:

try {

   PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);

   for (Signature signature : info.signatures) 
   {
    MessageDigest md = MessageDigest.getInstance("SHA");
    md.update(signature.toByteArray());
    Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
   }

  } catch (NameNotFoundException e) {
   Log.e("name not found", e.toString());
  } catch (NoSuchAlgorithmException e) {
   Log.e("no such an algorithm", e.toString());
  }

:

http://limbaniandroid.blogspot.com/2013/04/how-to-get-hash-key-for-integarte.html

0

Source: https://habr.com/ru/post/1792490/


All Articles