Ejemplo n.º 1
0
 /**
  * Set the key to use for the cipher
  *
  * @param string $key The key to use
  *
  * @throws InvalidArgumentException If the key is not the correct size
  * @return void
  */
 public function setKey($key)
 {
     switch ($this->cipher) {
         case 'rijndael-128':
         case 'rijndael-192':
         case 'rijndael-256':
             if (!in_array(strlen($key), array(16, 20, 24, 28, 32))) {
                 throw new \InvalidArgumentException(sprintf('The supplied key block is in the valid sizes [%d:%s]', strlen($key), '16, 20, 24, 28, 32'));
             }
             $this->keySize = strlen($key);
         default:
             parent::setKey($key);
     }
 }