@Override //storedValue must take form of ENC(...) public boolean compare(char[] inputValue, String storedValue) { String storedHash = storedValue.substring(4, storedValue.length() - 1); return codec.verify(inputValue, storedHash); } }
@Override //storedValue must take form of ENC(...) public boolean compare(char[] inputValue, String storedValue) { String storedHash = storedValue.substring(4, storedValue.length() - 1); return codec.verify(inputValue, storedHash); } }
@Override //storedValue must take form of ENC(...) public boolean compare(char[] inputValue, String storedValue) { String storedHash = storedValue.substring(4, storedValue.length() - 1); return codec.verify(inputValue, storedHash); } }
@Override //storedValue must take form of ENC(...) public boolean compare(char[] inputValue, String storedValue) { String storedHash = storedValue.substring(4, storedValue.length() - 1); return codec.verify(inputValue, storedHash); } }
@Override //storedValue must take form of ENC(...) public boolean compare(char[] inputValue, String storedValue) { String storedHash = storedValue.substring(4, storedValue.length() - 1); return codec.verify(inputValue, storedHash); } }
@Override //storedValue must take form of ENC(...) public boolean compare(char[] inputValue, String storedValue) { String storedHash = storedValue.substring(4, storedValue.length() - 1); return codec.verify(inputValue, storedHash); } }
@Override //storedValue must take form of ENC(...) public boolean compare(char[] inputValue, String storedValue) { String storedHash = storedValue.substring(4, storedValue.length() - 1); return codec.verify(inputValue, storedHash); } }
@Test public void testOnewayAlgorithm() throws Exception { DefaultSensitiveStringCodec codec = new DefaultSensitiveStringCodec(); Map<String, String> params = new HashMap<>(); params.put(DefaultSensitiveStringCodec.ALGORITHM, DefaultSensitiveStringCodec.ONE_WAY); codec.init(params); String plainText = "some_password"; String maskedText = codec.encode(plainText); System.out.println("encoded value: " + maskedText); //one way can't decode try { codec.decode(maskedText); fail("one way algorithm can't decode"); } catch (IllegalArgumentException expected) { } assertTrue(codec.verify(plainText.toCharArray(), maskedText)); String otherPassword = "some_other_password"; assertFalse(codec.verify(otherPassword.toCharArray(), maskedText)); }