diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index e0b333f2..903fdc5c 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -362,7 +362,7 @@ class Crypt_DES { */ function setKey($key) { - $this->keys = ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) ? substr($key, 0, 8) : $this->_prepareKey($key); + $this->keys = ( CRYPT_DES_MODE == CRYPT_DES_MODE_MCRYPT ) ? str_pad(substr($key, 0, 8), 8, chr(0)) : $this->_prepareKey($key); $this->changed = true; } diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index f2212c69..f6f281f8 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -532,7 +532,7 @@ class Crypt_Rijndael { */ function setKey($key) { - $this->key = $key; + $this->key = str_pad(substr($key, 0, $this->key_size), $this->key_size, chr(0)); $this->changed = true; }