ms4w php配置xdebug

ms4w是mapserver 的windows版本,其安装方便,集成了apache、php,但正是因为其集成,所以导致新手对其结构层次不是很清楚,当使用php开发时又急需调试功能,这里是配置xdebug进行调试的实践尝试,成功之后,特写此文章以备后用,同时也与大家分享。

欢迎大家转载,请注明出处 [by 叫我小艺]

ms4w\Apache\cgi-bin文件夹下

[1] 找到php5ts.dll,复制一份并重命名为:php5.dll

[2] 打开php.ini文件

找到extension末尾部分模块配置之前的注释部分

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

;;加上如下设置

zend_extension="D:/ms4w/Apache/php/ext/php_xdebug-2.2.2-5.4-vc9.dll"       ;  下载地址
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

可以通过cmd运行  (需要具体路径)php-cgi.exe -v 查看配置成功与否

最后出现了with Xdebug等字样

如果有其他错误,可能因为版本不对等;

[3] 重启apache

[4] 调用phpinfo();查看Xdebug的配置情况

出现类似内容就说明配置成功了。

[5] 然后在netbeans中进行调试配置

主要填写端口之类的,要与配置文件中的一致。

[6] 打断点进行调试实验

调试运行及变量监视

转载于:https://www.cnblogs.com/ganb/p/3448657.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MS4是一种加密算法,它包括加密和解密两个过程。下面是PHP 7中实现MS4加解密的代码示例: ```php <?php class MS4 { const BLOCK_SIZE = 8; const ROUNDS = 10; private $key; private $sbox; public function __construct($key) { $this->key = $this->expandKey($key); $this->sbox = $this->generateSBox(); } public function encrypt($plaintext) { $blocks = $this->pad($plaintext); $ciphertext = ''; foreach ($blocks as $block) { $x = $this->byteArrayToInt($block); for ($i = 0; $i < self::ROUNDS; $i++) { $x = $this->substitute($x); $x = $this->permute($x); $x ^= $this->key[$i]; } $ciphertext .= $this->intToByteArray($x); } return $ciphertext; } public function decrypt($ciphertext) { $blocks = str_split($ciphertext, self::BLOCK_SIZE); $plaintext = ''; foreach ($blocks as $block) { $x = $this->byteArrayToInt($block); for ($i = self::ROUNDS - 1; $i >= 0; $i--) { $x ^= $this->key[$i]; $x = $this->permuteInverse($x); $x = $this->substituteInverse($x); } $plaintext .= $this->intToByteArray($x); } return $this->unpad($plaintext); } private function expandKey($key) { $expandedKey = []; $keyLength = strlen($key); for ($i = 0; $i < self::ROUNDS; $i++) { $keyIndex = $i % $keyLength; $expandedKey[$i] = ord($key[$keyIndex]); } return $expandedKey; } private function generateSBox() { $sbox = []; for ($i = 0; $i < 256; $i++) { $sbox[$i] = $i ^ 0x55; } return $sbox; } private function substitute($x) { $y = 0; for ($i = 0; $i < self::BLOCK_SIZE; $i++) { $byte = ($x >> ($i * 8)) & 0xFF; $substitutedByte = $this->sbox[$byte]; $y |= $substitutedByte << ($i * 8); } return $y; } private function substituteInverse($y) { $x = 0; for ($i = 0; $i < self::BLOCK_SIZE; $i++) { $byte = ($y >> ($i * 8)) & 0xFF; $substitutedByte = $this->sbox[$byte]; $x |= $substitutedByte << ($i * 8); } return $x; } private function permute($x) { $y = 0; for ($i = 0; $i < self::BLOCK_SIZE; $i++) { $byte = ($x >> ($i * 8)) & 0xFF; $permutatedByte = (($byte << 1) | ($byte >> 7)) & 0xFF; $y |= $permutatedByte << ($i * 8); } return $y; } private function permuteInverse($y) { $x = 0; for ($i = 0; $i < self::BLOCK_SIZE; $i++) { $byte = ($y >> ($i * 8)) & 0xFF; $permutatedByte = (($byte >> 1) | ($byte << 7)) & 0xFF; $x |= $permutatedByte << ($i * 8); } return $x; } private function pad($data) { $padLength = self::BLOCK_SIZE - (strlen($data) % self::BLOCK_SIZE); $padding = str_repeat(chr($padLength), $padLength); return str_split($data . $padding, self::BLOCK_SIZE); } private function unpad($data) { $padLength = ord($data[strlen($data) - 1]); return substr($data, 0, strlen($data) - $padLength); } private function byteArrayToInt($byteArray) { $intValue = 0; for ($i = 0; $i < self::BLOCK_SIZE; $i++) { $intValue |= ord($byteArray[$i]) << ($i * 8); } return $intValue; } private function intToByteArray($intValue) { $byteArray = ''; for ($i = 0; $i < self::BLOCK_SIZE; $i++) { $byteArray .= chr(($intValue >> ($i * 8)) & 0xFF); } return $byteArray; } } $key = 'secretkey'; $plaintext = 'hello world'; $ms4 = new MS4($key); $ciphertext = $ms4->encrypt($plaintext); $decrypted = $ms4->decrypt($ciphertext); echo "Plaintext: $plaintext\n"; echo "Ciphertext: $ciphertext\n"; echo "Decrypted: $decrypted\n"; ``` 在上面的示例中,我们定义了一个MS4类,它包含了MS4加密和解密的方法。在构造函数中,我们将密钥扩展为一个长度为10的数组,并生成S盒。在加密过程中,我们将明文分割成8字节的块,并对每个块执行10轮加密。在加密过程中,我们将密钥的每个字节与S盒进行异或操作,并进行置换和代替操作。在解密过程中,我们将密文分割成8字节的块,并对每个块执行10轮解密,我们也将密钥的每个字节与S盒进行异或操作,并进行置换和代替操作。最后,我们将解密后的块组合成明文并去除填充。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值