@Test public void testHashSha256() throws Exception { assertEquals(PasswordHasher.sha256("mysalt", "mypassword"), "d02878b06efa88579cd84d9e50b211c0a7caa92cf243bad1622c66081f7e2692"); assertEquals(PasswordHasher.sha256("", "mypassword"), "89e01536ac207279409d4de1e5253e01f4a1769e696db0d6062ca9b8f56767c8"); assertEquals(PasswordHasher.sha256(null, "mypassword"), "89e01536ac207279409d4de1e5253e01f4a1769e696db0d6062ca9b8f56767c8"); }
public static String sha256(String salt, String password) { if (salt == null) salt = ""; byte[] bytes = (salt + password).getBytes(Charsets.UTF_8); HashCode hash = Hashing.sha256().hashBytes(bytes); return hash.toString(); }
PasswordHasher { public static String sha256(String salt, String password) { if (salt == null) salt = ""; byte[] bytes = (salt + password).getBytes(Charsets.UTF_8); HashCode hash = Hashing.sha256().hashBytes(bytes); return hash.toString(); } }
PasswordHasher { public static String sha256(String salt, String password) { if (salt == null) salt = ""; byte[] bytes = (salt + password).getBytes(Charsets.UTF_8); HashCode hash = Hashing.sha256().hashBytes(bytes); return hash.toString(); }  }
PasswordHasher { public static String sha256(String salt, String password) { if (salt == null) salt = ""; byte[] bytes = (salt + password).getBytes(Charsets.UTF_8); HashCode hash = Hashing.sha256().hashBytes(bytes); return hash.toString(); }  static String sha256(String salt, String password); }
PasswordHasher { public static String sha256(String salt, String password) { if (salt == null) salt = ""; byte[] bytes = (salt + password).getBytes(Charsets.UTF_8); HashCode hash = Hashing.sha256().hashBytes(bytes); return hash.toString(); }  static String sha256(String salt, String password);  }