@Test public void shouldReturnDifferentString() { MasterPasswordStore.setMasterPassword("top-secret-passw0rd"); String text = "ABCDE12345!@#$%"; TextCoder coder = new TextCoder(); String encoded = coder.encode(text); assertThat(encoded).isNotEqualTo(text); }
public String encode(String text) { try { Cipher cipher = createCipher(Cipher.ENCRYPT_MODE, MasterPasswordStore.getMasterPassword(), SALT); byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8")); return DatatypeConverter.printBase64Binary(encrypted); } catch (Exception e) { throw new RuntimeException(e); } }
TextCoder { public String encode(String text) { try { Cipher cipher = createCipher(Cipher.ENCRYPT_MODE, MasterPasswordStore.getMasterPassword(), SALT); byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8")); return DatatypeConverter.printBase64Binary(encrypted); } catch (Exception e) { throw new RuntimeException(e); } } }
TextCoder { public String encode(String text) { try { Cipher cipher = createCipher(Cipher.ENCRYPT_MODE, MasterPasswordStore.getMasterPassword(), SALT); byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8")); return DatatypeConverter.printBase64Binary(encrypted); } catch (Exception e) { throw new RuntimeException(e); } }  }
TextCoder { public String encode(String text) { try { Cipher cipher = createCipher(Cipher.ENCRYPT_MODE, MasterPasswordStore.getMasterPassword(), SALT); byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8")); return DatatypeConverter.printBase64Binary(encrypted); } catch (Exception e) { throw new RuntimeException(e); } }  String encode(String text); String decode(String text); }
TextCoder { public String encode(String text) { try { Cipher cipher = createCipher(Cipher.ENCRYPT_MODE, MasterPasswordStore.getMasterPassword(), SALT); byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8")); return DatatypeConverter.printBase64Binary(encrypted); } catch (Exception e) { throw new RuntimeException(e); } }  String encode(String text); String decode(String text);  }