/** * Constructor set settings for encryption * * @param array $config array ( * 'key' => string, * 'cipher' => MCRYPT_ciphername, * 'mode' => MCRYPT_MODE_modename * ) * @return Encryption */ public function __construct(array $config = array()) { // Set general settings $this->key = ArrayUtils::arrayTarget('key', $config, 'mykey'); $this->cipher = ArrayUtils::arrayTarget('cipher', $config, MCRYPT_RIJNDAEL_256); $this->mode = ArrayUtils::arrayTarget('mode', $config, MCRYPT_MODE_CFB); // Calculate IV Size $this->ivSize = mcrypt_get_iv_size($this->cipher, $this->mode); }
public function testArrayTarget() { $testArray = array('suite' => array('test' => true, 'live' => false)); $result = ArrayUtils::arrayTarget('suite', $testArray, false); $this->assertInternalType('array', $result); $result = ArrayUtils::arrayTarget('suite.live', $testArray, null); $this->assertEquals(null, $result); $result = ArrayUtils::arrayTarget('suite.non', $testArray, false); $this->assertEquals(false, $result); $result = ArrayUtils::arrayTarget('suite.test.live', $result, 'nothing'); $this->assertEquals('nothing', $result); }