private static function validateKey($key, $size)
    {
        $length = strlen($key);

        if ($length < $size) {
            $key = str_pad($key, $size, $key);
        } elseif ($length > $size) {
            $key = substr($key, 0, $size);
        }

        return $key;
    }
private static function validateKey($key, $size)
    {
        $length = strlen($key);

        if ($length < $size) {
            $key = str_pad($key, $size, $key);
        } elseif ($length > $size) {
            $key = substr($key, 0, $size);
        }

        return $key;
    }
private static function validateKey ( $ key , $ size ) { $ length = strlen ( $ key ) ; if ( $ length < $ size ) { $ key = str_pad ( $ key , $ size , $ key ) ; } elseif ( $ length > $ size ) { $ key = substr ( $ key , 0 , $ size ) ; } return $ key ; }
Validate a key relative to maximum supported keysize of the opened mode.

@param string $key  : The key to validate
@param int    $size : The size of the key (check with mcrypt_enc_get_key_size)

@return string $key : The validated key
Validate a key relative to maximum supported keysize of the opened mode .