HaloUtils { @Api(2.0) public static String sha1(@NonNull String origin) throws UnsupportedEncodingException, NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("SHA-1"); md.update(origin.getBytes("iso-8859-1"), 0, origin.length()); byte[] sha1hash = md.digest(); return convertToHex(sha1hash); } private  HaloUtils(); @Api(1.0) static boolean isNetworkConnected(Context context); @Api(2.0) static boolean isCharging(@NonNull Context context, @Nullable Intent intent); @Api(1.0) static void hideKeyboard(@Nullable View focusView); @Api(1.0) static void postUI(Runnable runnable); @Api(1.0) static boolean isAvailableForVersion(int sdkVersion); @Api(1.0) @SuppressWarnings("deprecation") static Drawable getDrawable(Context context, @DrawableRes int resource); @Api(1.0) static Uri getUriFromResource(Context context, int resourceId); @Api(1.0) static boolean hasFlag(int flags, int optionFlag); @Api(1.0) static int getArgb(String hexadecimal); @Api(1.0) static boolean isColor(String color); @Api(2.0) static String sha1(@NonNull String origin); @Api(2.0) static String convertToHex(byte[] data); @NonNull @Api(1.3) static String getEventName(@NonNull Context context, @NonNull String eventName); @Api(2.0) static String bytesToHex(@NonNull byte[] bytes); @Api(2.0) static byte[] hexToBytes(@NonNull String data); @Api(2.5) static boolean isServiceRunning(Context context, Class<?> serviceClass);  }
@Test public void thatSha1CreateHash() throws UnsupportedEncodingException, NoSuchAlgorithmException { String textToHash = "HaloNetClientTest"; assertThat(HaloUtils.sha1(textToHash)).isEqualTo(HaloUtils.sha1("HaloNetClientTest")); }