code: public static String getSignatureHexCode(Context context, String targetPackageName) {
          if (TextUtils.isEmpty(targetPackageName)) {
              return null;
          }
          try {
              PackageInfo info = PackageManagerUtils.getSignaturePackageInfo(context, targetPackageName);
              if (info.signatures.length != 1) {
                  // multiple signature would not treated
                  return null;
              }
              Signature sig = info.signatures[0];
              byte[] sha256 = MessageDigestUtils.computeSha256(sig.toByteArray());
              return StringUtils.byteToHex(sha256);
          } catch (NameNotFoundException e) {
              Log.e(TAG, "target package not found: ", e);
              return null;
          }
      }
docs: Obtains the signature hex code.
  @param context the context.
  @param targetPackageName the target package name.
  @return the hex code of the signature.