Back to Mcrypt class

Method setEncryptionMode

public void
setEncryptionMode
(mixed $mode = 'cbc', mixed $strength = 128)
Set the encryption mode
Parameters
  • string $mode Encryption Mode
  • int $strength Encryption Strength
Returns
  • void
Class: Mcrypt
Project: Joomla

Method setEncryptionMode - Source code

/**
 * Set the encryption mode
 *
 * @param   string   $mode      Encryption Mode
 * @param   integer  $strength  Encryption Strength
 *
 * @return   void
 */
public function setEncryptionMode($mode = 'cbc', $strength = 128)
{
    switch ((int) $strength) {
        default:
        case '128':
            $this->cipherType = MCRYPT_RIJNDAEL_128;
            break;
        case '192':
            $this->cipherType = MCRYPT_RIJNDAEL_192;
            break;
        case '256':
            $this->cipherType = MCRYPT_RIJNDAEL_256;
            break;
    }
    switch (strtolower($mode)) {
        case 'ecb':
            $this->cipherMode = MCRYPT_MODE_ECB;
            break;
        default:
        case 'cbc':
            $this->cipherMode = MCRYPT_MODE_CBC;
            break;
    }
}