-1

I'm having trouble with the conventional way of generating a keyhash in fb, which requires openssl and a lengthy process...

I was wondering if I could just type in 28 random characters and use that string as my keyhash? .

Fuad
  • 1,187
  • 1
  • 12
  • 30
  • that will not work, you have to generate key hash.. – Akhil Jun 07 '15 at 06:15
  • possible duplicate of [How to create Android Facebook Key Hash?](http://stackoverflow.com/questions/7506392/how-to-create-android-facebook-key-hash) – YFeizi Jun 07 '15 at 06:48
  • The keyhash is not some random number you type in and get on with life.No offense but in the time it took you to write this and wait for an answer, you could have gone through one of these [lenghty processes](http://stackoverflow.com/questions/5306009/facebook-android-generate-key-hash?lq=1) – Ojonugwa Jude Ochalifu Jun 07 '15 at 06:50
  • no @y.feizi I was asking if random numbers will work, so it is not a duplicate – Fuad Jun 07 '15 at 07:08
  • you can use a tool that i built for ios and windows http://stackoverflow.com/a/17732453/2226605 and upvote my answer there if that helped you. Thanks – Shahar Jan 16 '16 at 20:35

2 Answers2

1
           try {
              PackageInfo info = getPackageManager().getPackageInfo(
                "yourpackagename", 
                PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.e("KeyHash:", Base64.encodeToString(md.digest(),Base64.DEFAULT));
            }
    } catch (NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }
Deepanshu Gandhi
  • 492
  • 3
  • 10
  • Log.e("KeyHash:", Base64.encodeToString(md.digest(),Base64.DEFAULT)); will print your keyhash cpy it and paste in our fb app settings – Deepanshu Gandhi Jun 07 '15 at 06:25
  • you can put this code anywhere is your app but i will recommend to put it in your first activity and then you will get a log in your logcat copy the keyhash and then paste it in your facebook settings and then you are done – Deepanshu Gandhi Jun 07 '15 at 06:36
0
//Call this method for KeyHash  
    String keyHash = getKeyHashForFacebook(SplashScreen.this);
    Log.e("keyHash  ", keyHash);


    public static String getKeyHashForFacebook(Context context) {
            try {
                PackageInfo info = context.getPackageManager().getPackageInfo(
                        context.getApplicationContext().getPackageName(), PackageManager.GET_SIGNATURES);
                for (Signature signature : info.signatures) {
                    MessageDigest md = MessageDigest.getInstance("SHA");
                    md.update(signature.toByteArray());
                    return "KeyHash:" + context.getApplicationContext().getPackageName() + "=>"
                            + Base64.encodeToString(md.digest(), Base64.DEFAULT);
                }
            } catch (Exception e) {
    e.printStackTrace();

            }
            return "=>";
        }

@fuad check this out for Logcat http://developer.android.com/tools/help/logcat.html ![check Logcat for KeyHash 1

enter image description here

Logcat

Sahir Saiyed
  • 468
  • 7
  • 17