### Question:
CipherDelegator { public static Map.Entry<String, String> encrypt(String strToEncrypt) throws SakuliCipherException { loadEnvironmentVariables(); Properties props = new Properties(); SakuliPropertyPlaceholderConfigurer.assignEncryptionProperties(props); CipherProperties cipherProps = CipherProperties.load(props); switch (cipherProps.getEncryptionMode()) { case CipherProperties.ENCRYPTION_MODE_ENVIRONMENT: return new AbstractMap.SimpleEntry<>("environment masterkey", new EnvironmentCipher(cipherProps).encrypt(strToEncrypt)); case CipherProperties.ENCRYPTION_MODE_INTERFACE: NetworkInterfaceCipher cipher = new NetworkInterfaceCipher(cipherProps); cipher.scanNetworkInterfaces(); return new AbstractMap.SimpleEntry<>("interface " + cipher.getInterfaceName(), cipher.encrypt(strToEncrypt)); default: throw new SakuliCipherException("unexpected error during encryption"); } }  static Map.Entry<String, String> encrypt(String strToEncrypt);  }### Answer:
@Test public void testEncryptKey() throws Exception { String testSecret = "my-test-val"; final String masterkey = AesKeyHelper.createRandomBase64Key(); SakuliPropertyPlaceholderConfigurer.ENCRYPTION_KEY_VALUE = masterkey; final Map.Entry<String, String> kv = CipherDelegator.encrypt(testSecret); assertEquals(kv.getKey(), "environment masterkey"); assertTrue(kv.getValue().length() > testSecret.length()); CipherProperties props = new CipherProperties(); props.setEncryptionKey(masterkey); assertEquals(new EnvironmentCipher(props).decrypt(kv.getValue()), testSecret); }
@Test public void testEncryptInterface() throws Exception { String testSecret = "my-test-val"; SakuliPropertyPlaceholderConfigurer.ENCRYPTION_INTERFACE_VALUE = "auto"; final Map.Entry<String, String> kv = CipherDelegator.encrypt(testSecret); BaseTest.assertContains(kv.getKey(), "interface "); assertTrue(kv.getValue().length() > testSecret.length()); CipherProperties props = new CipherProperties(); props.setEncryptionInterfaceAutodetect(true); final NetworkInterfaceCipher networkInterfaceCipher = new NetworkInterfaceCipher(props); networkInterfaceCipher.scanNetworkInterfaces(); assertEquals(networkInterfaceCipher.decrypt(kv.getValue()), testSecret); }