1. Using OpenSSL and command prompt
Using below code snippet, you can get the hash code.
super.onCreate(savedInstanceState);
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
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) {
Check your logcat output for a message.
Follow @amardeepvijay
- Download openssl from Download
- Extract it. Create a folder- OpenSSL in C: / and copy all files here
- Find “debug.keystore” file path. Most likely it will be inside “C:\Users\\.android” folder. In my system it is under “C:\Program Files\Java\jdk1.7.0_67\bin”
- Open command prompt (Run-> cmd->start) and go to java /bin folder (cd “C:\Program Files\Java\jdk1.7.0_67\bin” command will do it for you)
C:\\Program Files\\Java\\jdk1.6.0_30\\bin>keytool -exportcert -alias androiddebugkey -keystore "C:\\Users\\.android\\debug.keystore" | "C:\\OpenSSL\\bin\\openssl" sha1 -binary |"C:\\OpenSSL\bin\\openssl" base64
Enter keystore password:android
2. Using a method call from android codeUsing below code snippet, you can get the hash code.
@Overridepublic void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add code to print out the key hash
try {
PackageInfo info = getPackageManager().getPackageInfo(
"com.facebook.samples.hellofacebook",
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) {
Hi there, You've done a fantastic job. I’ll certainly digg it and personally recommend to my friends. I'm confident they'll be benefited from this site. apple support berlin
ReplyDeleteOne of the knowledge stuffed blogs i've ever seen. It helps revamp existing technology and architecture, using constantly evolving strategies to drive improved market performance. reffer the given blog for more info Application Modernization Services or
ReplyDeletereach +18882075969 for more information
Really helpfull and easiest way to understand the concepts. Thanks for sharing please continue this wonderfull Work. If you want to know Anything about mendix Dont hesitate to Visit Mendix Certified developers | Mendix License or Reach out me @ +18882075969
ReplyDeleteThank you for sharing. Keep posting.
ReplyDeleteMobile App Development Company in Gurgaon India
Android app development company in Gurgaon India
Lets visit Get Pinterest Photos and Pictures
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI just read your blog and I must say, it's truly remarkable! Your writing style is engaging, and your insights are thought-provoking. Keep up the great work!
ReplyDeleteAs Maven Technology we named as Best Website Development Company in Delhi : Here you unleash digital potential with cutting-edge solutions across all digital channels. From responsive design to user-friendly interfaces, we excel at creating compelling websites that drive results.
Let's transform your digital presence today.