Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.Signature; import android.util.Base64; import android.util.Log; import java.security.MessageDigest; public class Main { /** * Prints your current certificate signature to the Logcat. Use this method to obtain your certificate signature. * * @param context The application context. */ public static void getCertificateSignature(Context context) { try { PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES); // The APK is signed with multiple signatures, probably it was tampered. if (packageInfo.signatures.length > 1) { return; } for (Signature signature : packageInfo.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.d("TAMPERING_PROTECTION", "**" + Base64.encodeToString(md.digest(), Base64.DEFAULT) + "**"); } } catch (Exception exception) { Log.d("TAMPERING_PROTECTION", exception.getStackTrace().toString()); } } }