@Test public void testCompare() throws Exception { SecureRandom random = new SecureRandom(); Sha256Hasher hasher = new Sha256Hasher(); hasher.init(); String password; for (int i =0; i < 100; i++){ password = new BigInteger(130, random).toString(32); Assert.assertTrue(hasher.compare(password, hasher.transform(password))); Assert.assertFalse(hasher.compare("notPassword", hasher.transform(password))); } password = "lkfdjsafd:fldksaalsd"; Assert.assertTrue(hasher.compare(password, hasher.transform(password))); Assert.assertFalse(hasher.compare("notPassword", hasher.transform(password))); }
@PostConstruct public void init() { rn = new SecureRandom(); }
Sha256Hasher extends Hasher { @PostConstruct public void init() { rn = new SecureRandom(); } }
Sha256Hasher extends Hasher { @PostConstruct public void init() { rn = new SecureRandom(); }  }
Sha256Hasher extends Hasher { @PostConstruct public void init() { rn = new SecureRandom(); }  @PostConstruct void init(); @Override String hash(String value); @Override boolean compareInternal(String plainText, String previousHash); @Override String getName(); }
Sha256Hasher extends Hasher { @PostConstruct public void init() { rn = new SecureRandom(); }  @PostConstruct void init(); @Override String hash(String value); @Override boolean compareInternal(String plainText, String previousHash); @Override String getName();  }