public function testEncryption() { $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 'encryptionKeyValue'; $encrypted = Tools::encrypt('my value'); $this->assertNotSame('my value', $encrypted, 'must be encrypted'); $decrypted = Tools::decrypt($encrypted); $this->assertSame('my value', $decrypted, 'must be original value'); }
/** * Returns the decrypted field value if set. * @param array $PA Parameter Array * @return string */ public static function getDecryptedFieldValue($field, $value) { $default = @$GLOBALS['TCA']['tx_newsletter_domain_model_bounceaccount']['columns'][$field]['config']['default']; // Set the value if (empty($value)) { if ($default) { $value = $default; } } elseif ($value != $default) { $value = \Ecodev\Newsletter\Tools::decrypt($value); } return $value; }
public function getSubstitutedConfig() { $markers = ['###SERVER###', '###PROTOCOL###', '###PORT###', '###USERNAME###', '###PASSWORD###']; $values = []; $values[] = $this->getServer(); $values[] = $this->getProtocol(); $values[] = $this->getPort(); $values[] = $this->getUsername(); $values[] = \Ecodev\Newsletter\Tools::decrypt($this->getPassword()); $config = $this->getConfig(); if (empty($config)) { // Keep the old config to not break old installations $config = 'poll ###SERVER### proto ###PROTOCOL### username "###USERNAME###" password "###PASSWORD###"'; } else { $config = \Ecodev\Newsletter\Tools::decrypt($config); } $result = str_replace($markers, $values, $config); unset($values); // Dont leave unencrypted values in memory around for too long. return $result; }