@Test public void testCalcFingerprintString() { assertEquals(fdroidFingerprint, Utils.calcFingerprint(fdroidPubkey)); assertEquals(gpRepoFingerprint, Utils.calcFingerprint(gpRepoPubkey)); assertEquals(gpTest0Fingerprint, Utils.calcFingerprint(gpTest0Pubkey)); assertEquals(gpTest1Fingerprint, Utils.calcFingerprint(gpTest1Pubkey)); assertFalse(gpRepoFingerprint.equals( Utils.calcFingerprint(fdroidPubkey))); assertFalse(gpTest0Fingerprint.equals( Utils.calcFingerprint(fdroidPubkey))); assertFalse(gpTest1Fingerprint.equals( Utils.calcFingerprint(fdroidPubkey))); assertFalse(fdroidFingerprint.equals( Utils.calcFingerprint(gpRepoPubkey))); assertFalse(gpTest0Fingerprint.equals( Utils.calcFingerprint(gpRepoPubkey))); assertFalse(gpTest1Fingerprint.equals( Utils.calcFingerprint(gpRepoPubkey))); assertFalse(fingerprintShortByOneFingerprint.equals( Utils.calcFingerprint(fingerprintShortByOnePubkey))); assertFalse(fingerprintLongByOneFingerprint.equals( Utils.calcFingerprint(fingerprintLongByOnePubkey))); try { assertFalse(pubkeyShortByOneFingerprint.equals( Utils.calcFingerprint(pubkeyShortByOnePubkey))); } catch (ArrayIndexOutOfBoundsException e) { assertTrue(true); } try { assertFalse(pubkeyLongByOneFingerprint.equals( Utils.calcFingerprint(pubkeyLongByOnePubkey))); } catch (ArrayIndexOutOfBoundsException e) { assertTrue(true); } }
public static String calcFingerprint(String keyHexString) { if (TextUtils.isEmpty(keyHexString) || keyHexString.matches(".*[^a-fA-F0-9].*")) { Log.e(TAG, "Signing key certificate was blank or contained a non-hex-digit!"); return null; } return calcFingerprint(Hasher.unhex(keyHexString)); }
Utils { public static String calcFingerprint(String keyHexString) { if (TextUtils.isEmpty(keyHexString) || keyHexString.matches(".*[^a-fA-F0-9].*")) { Log.e(TAG, "Signing key certificate was blank or contained a non-hex-digit!"); return null; } return calcFingerprint(Hasher.unhex(keyHexString)); } }
Utils { public static String calcFingerprint(String keyHexString) { if (TextUtils.isEmpty(keyHexString) || keyHexString.matches(".*[^a-fA-F0-9].*")) { Log.e(TAG, "Signing key certificate was blank or contained a non-hex-digit!"); return null; } return calcFingerprint(Hasher.unhex(keyHexString)); }  }
Utils { public static String calcFingerprint(String keyHexString) { if (TextUtils.isEmpty(keyHexString) || keyHexString.matches(".*[^a-fA-F0-9].*")) { Log.e(TAG, "Signing key certificate was blank or contained a non-hex-digit!"); return null; } return calcFingerprint(Hasher.unhex(keyHexString)); }  static String getIconsDir(final Context context, final double dpiMultiplier); static File getImageCacheDir(Context context); static long getImageCacheDirAvailableMemory(Context context); static long getImageCacheDirTotalMemory(Context context); static void copy(InputStream input, OutputStream output); static boolean symlinkOrCopyFileQuietly(SanitizedFile inFile, SanitizedFile outFile); static void consumeStream(InputStream stream); static boolean copyQuietly(File inFile, File outFile); static void closeQuietly(Closeable closeable); static String getFriendlySize(long size); static String getAndroidVersionName(int sdkLevel); static String formatFingerprint(Context context, String fingerprint); @NonNull static Uri getLocalRepoUri(Repo repo); static Uri getSharingUri(Repo repo); static Uri getPackageUri(String packageName); static String calcFingerprint(String keyHexString); static String calcFingerprint(Certificate cert); static String getPackageSig(PackageInfo info); static Locale getLocaleFromAndroidLangTag(String languageTag); static DisplayImageOptions.Builder getDefaultDisplayImageOptionsBuilder(); static DisplayImageOptions getRepoAppDisplayImageOptions(); static void setIconFromRepoOrPM(@NonNull App app, ImageView iv, Context context); static String hashBytes(byte[] input, String algo); @Nullable static String getBinaryHash(File apk, String algo); static String toHexString(byte[] bytes); static int parseInt(String str, int fallback); @Nullable static String[] parseCommaSeparatedString(String values); @Nullable static String serializeCommaSeparatedString(@Nullable String[] values); static Date parseDate(String str, Date fallback); static String formatDate(Date date, String fallback); static Date parseTime(String str, Date fallback); static String formatTime(Date date, String fallback); static CharSequence formatAppNameAndSummary(String appName, String summary); static boolean isSafePackageName(@Nullable String packageName); static int daysSince(@NonNull Date date); static String formatLastUpdated(@NonNull Resources res, @NonNull Date date); static void debugLog(String tag, String msg); static void debugLog(String tag, String msg, Throwable tr); static String getVersionName(Context context); static PackageInfo getPackageInfo(Context context, String packageName); @SuppressWarnings("unused") @RequiresApi(api = 11) static List<Map<String, String>> dumpCursor(Cursor cursor); static int dpToPx(int dp, Context ctx); static int bytesToKb(long bytes); static int getPercent(long current, long total); static void showToastFromService(final Context context, final String msg, final int length); static void applySwipeLayoutColors(SwipeRefreshLayout swipeLayout); static boolean canConnectToSocket(String host, int port); static boolean isServerSocketInUse(int port); }
Utils { public static String calcFingerprint(String keyHexString) { if (TextUtils.isEmpty(keyHexString) || keyHexString.matches(".*[^a-fA-F0-9].*")) { Log.e(TAG, "Signing key certificate was blank or contained a non-hex-digit!"); return null; } return calcFingerprint(Hasher.unhex(keyHexString)); }  static String getIconsDir(final Context context, final double dpiMultiplier); static File getImageCacheDir(Context context); static long getImageCacheDirAvailableMemory(Context context); static long getImageCacheDirTotalMemory(Context context); static void copy(InputStream input, OutputStream output); static boolean symlinkOrCopyFileQuietly(SanitizedFile inFile, SanitizedFile outFile); static void consumeStream(InputStream stream); static boolean copyQuietly(File inFile, File outFile); static void closeQuietly(Closeable closeable); static String getFriendlySize(long size); static String getAndroidVersionName(int sdkLevel); static String formatFingerprint(Context context, String fingerprint); @NonNull static Uri getLocalRepoUri(Repo repo); static Uri getSharingUri(Repo repo); static Uri getPackageUri(String packageName); static String calcFingerprint(String keyHexString); static String calcFingerprint(Certificate cert); static String getPackageSig(PackageInfo info); static Locale getLocaleFromAndroidLangTag(String languageTag); static DisplayImageOptions.Builder getDefaultDisplayImageOptionsBuilder(); static DisplayImageOptions getRepoAppDisplayImageOptions(); static void setIconFromRepoOrPM(@NonNull App app, ImageView iv, Context context); static String hashBytes(byte[] input, String algo); @Nullable static String getBinaryHash(File apk, String algo); static String toHexString(byte[] bytes); static int parseInt(String str, int fallback); @Nullable static String[] parseCommaSeparatedString(String values); @Nullable static String serializeCommaSeparatedString(@Nullable String[] values); static Date parseDate(String str, Date fallback); static String formatDate(Date date, String fallback); static Date parseTime(String str, Date fallback); static String formatTime(Date date, String fallback); static CharSequence formatAppNameAndSummary(String appName, String summary); static boolean isSafePackageName(@Nullable String packageName); static int daysSince(@NonNull Date date); static String formatLastUpdated(@NonNull Resources res, @NonNull Date date); static void debugLog(String tag, String msg); static void debugLog(String tag, String msg, Throwable tr); static String getVersionName(Context context); static PackageInfo getPackageInfo(Context context, String packageName); @SuppressWarnings("unused") @RequiresApi(api = 11) static List<Map<String, String>> dumpCursor(Cursor cursor); static int dpToPx(int dp, Context ctx); static int bytesToKb(long bytes); static int getPercent(long current, long total); static void showToastFromService(final Context context, final String msg, final int length); static void applySwipeLayoutColors(SwipeRefreshLayout swipeLayout); static boolean canConnectToSocket(String host, int port); static boolean isServerSocketInUse(int port); static final String FALLBACK_ICONS_DIR; }