@Test public void testComputeSHAHash () { String text = "text"; String expectedMD5Hash = "Ny6gjKsz5xwCxlHbyDpHTTLGduo="; String hash = HashUtils.computeSHAHash(text); assertEquals(expectedMD5Hash, hash); }
public static String computeSHAHash(String password) { MessageDigest mdSha1 = null; String SHAHash = ""; try { mdSha1 = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e1) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e1); throw new IllegalStateException("Cannot find SHA-1 algorithm.", e1); } mdSha1.update(password.getBytes(StandardCharsets.US_ASCII)); byte[] data = mdSha1.digest(); SHAHash = convertToHex(data); return SHAHash; }
HashUtils { public static String computeSHAHash(String password) { MessageDigest mdSha1 = null; String SHAHash = ""; try { mdSha1 = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e1) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e1); throw new IllegalStateException("Cannot find SHA-1 algorithm.", e1); } mdSha1.update(password.getBytes(StandardCharsets.US_ASCII)); byte[] data = mdSha1.digest(); SHAHash = convertToHex(data); return SHAHash; } }
HashUtils { public static String computeSHAHash(String password) { MessageDigest mdSha1 = null; String SHAHash = ""; try { mdSha1 = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e1) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e1); throw new IllegalStateException("Cannot find SHA-1 algorithm.", e1); } mdSha1.update(password.getBytes(StandardCharsets.US_ASCII)); byte[] data = mdSha1.digest(); SHAHash = convertToHex(data); return SHAHash; } protected  HashUtils(); }
HashUtils { public static String computeSHAHash(String password) { MessageDigest mdSha1 = null; String SHAHash = ""; try { mdSha1 = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e1) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e1); throw new IllegalStateException("Cannot find SHA-1 algorithm.", e1); } mdSha1.update(password.getBytes(StandardCharsets.US_ASCII)); byte[] data = mdSha1.digest(); SHAHash = convertToHex(data); return SHAHash; } protected  HashUtils(); static String computeSHAHash(String password); static String computePasswordSHAHash(String password); static String computeMD5Hash(String password); static String computeMD5FileHash(File file); }
HashUtils { public static String computeSHAHash(String password) { MessageDigest mdSha1 = null; String SHAHash = ""; try { mdSha1 = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e1) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e1); throw new IllegalStateException("Cannot find SHA-1 algorithm.", e1); } mdSha1.update(password.getBytes(StandardCharsets.US_ASCII)); byte[] data = mdSha1.digest(); SHAHash = convertToHex(data); return SHAHash; } protected  HashUtils(); static String computeSHAHash(String password); static String computePasswordSHAHash(String password); static String computeMD5Hash(String password); static String computeMD5FileHash(File file);  }