/** * Constructor * Sets the key used for encryption. Also sets the requied block size * * @param string $key string containing the user supplied encryption key * @return void */ public function __construct($key) { // SimpleXOR does not have a key size requirement parent::__construct(PHP_Crypt::CIPHER_SIMPLEXOR, $key); // required block size in bits $this->blockSize(self::BYTES_BLOCK); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { // set the key, make sure the required length is set in bytes parent::__construct(PHP_Crypt::CIPHER_3WAY, $key, self::BYTES_KEY); // set the block size $this->blockSize(self::BYTES_BLOCK); // initialize the round constants $this->initTables(); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { // set the Skipjack key parent::__construct(PHP_Crypt::CIPHER_SKIPJACK, $key, self::BYTES_KEY); // initialize variables $this->initTables(); // set the block size used $this->blockSize(self::BYTES_BLOCK); // expand the key from 10 bytes to 128 bytes $this->expandKey(); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { // the key must be between 1 and 128 bytes, keys larger than // 128 bytes are truncated in expandedKey() $keylen = strlen($key); if ($keylen < 1) { $err = "Key size is {$keylen} bits, Key size must be between 1 and 128 bytes"; trigger_error($err, E_USER_WARNING); } // set the key parent::__construct(PHP_Crypt::CIPHER_RC2, $key, $keylen); // set the block size $this->blockSize(self::BYTES_BLOCK); // initialize the tables $this->initTables(); // expand the key to 128 bytes $this->expandKey(); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { // the max length of the key is 448 bits (56 bytes) $keylen = strlen($key); if ($keylen > 56) { $key = substr($key, 0, 56); $keylen = 56; } else { if ($keylen < 1) { $msg = "No key given. The key must be between 1 - 56 bytes."; trigger_error($msg, E_USER_WARNING); } } // set the key, make sure the required length is set in bits parent::__construct(PHP_Crypt::CIPHER_BLOWFISH, $key, $keylen); // set the block size $this->blockSize(self::BYTES_BLOCK); $this->initTables(); $this->subKeys(); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { $keylen = strlen($key); if ($keylen > self::BYTES_KEY_MAX) { $key = substr($key, 0, self::BYTES_KEY_MAX); $keylen = self::BYTES_KEY_MAX; } else { if (!in_array($keylen, self::$_req_key_sizes)) { $msg = PHP_Crypt::CIPHER_CAST_256 . " requires a key size of 16, "; $msg .= "20, 24, 28, or 32 bytes."; trigger_error($msg, E_USER_WARNING); } } // set the key, make sure the required length is set in bytes parent::__construct(PHP_Crypt::CIPHER_CAST_256, $key, $keylen); // set the block size $this->blockSize(self::BYTES_BLOCK); // initialize the sboxes constants $this->initTables(); // create the sub keys using the sboxes $this->createSubKeys(); }
/** * Constructor * Sets the key used for encryption. Also sets the requied block size * * @param string The cipher name as set in a constant in the child class * @param string $key string containing the user supplied encryption key * @param integer $len Optional, the key size in bytes - used only by the AES child classes * @return void */ public function __construct($cipher_name, $key, $len = 0) { // AES will pass in a $len, since it has a fixed key size, other // rijndael implementations can use variable key sizes, supported // sizes are stored in self::$_key_sizes if ($len == 0) { // the key must be one of the following lengths: 16, 24, 32 bytes $len = strlen($key); if (!in_array($len, self::$_key_sizes)) { $msg = "Incorrect key length for " . strtoupper($cipher_name) . ". "; $msg .= "Received {$len} bytes."; trigger_error($msg, E_USER_WARNING); } } // Setup the key parent::__construct($cipher_name, $key, $len); // initialize the tables used for rijndael/aes $this->initTables(); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { // set the key parent::__construct(PHP_Crypt::CIPHER_VIGENERE, $key); $this->initTables(); }
/** * Second Constructor, used only by child classes that extend this class * * @param string $cipher The name of the cipher extending this class * @param string $key The key used for Encryption/Decryption * @param integer $key_byte_sz The required byte size of the extending cipher * @return void */ protected function __construct1($cipher, $key, $key_byte_sz) { // set the key and key size parent::__construct($cipher, $key, $key_byte_sz); // initialize variables $this->initTables(); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { // the length of the key is is between 5 - 16 bytes (40 - 128 bits) $keylen = strlen($key); if ($keylen > self::BYTES_KEY_MAX) { $key = substr($key, 0, self::BYTES_KEY_MAX); $keylen = self::BYTES_KEY_MAX; } else { if ($keylen < self::BYTES_KEY_MIN) { $msg = PHP_Crypt::CIPHER_CAST_128 . " requires a key size between "; $msg .= "5 - 16 bytes."; trigger_error($msg, E_USER_WARNING); } } // set the key, make sure the required length is set in bytes parent::__construct(PHP_Crypt::CIPHER_CAST_128, $key, $keylen); // set the block size $this->blockSize(self::BYTES_BLOCK); // initialize the sboxes constants $this->initTables(); // create the sub keys using the sboxes $this->createSubKeys(); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { // set the ARC4 key parent::__construct(PHP_Crypt::CIPHER_ARC4, $key); }
/** * Constructor * * @param string $key The key used for Encryption/Decryption * @return void */ public function __construct($key) { parent::__construct(PHP_Crypt::CIPHER_ENIGMA, $key, strlen($key)); $this->createKey(); }