为什么POST过来的sha1加密字符串相等的判断不对呢。
比如我表单post过来了sha1('1')这个加密后的字符串356a192b7913b04c54574d18c28d46e6395428ab。
然后我if($_POST['s']=='356a192b7913b04c54574d18c28d46e6395428ab')
为什么判断为false?
echo $_POST['s']也是356a192b7913b04c54574d18c28d46e6395428ab啊。。
回复讨论(解决方案)
仔细检查一下 $_POST['s'] 是不是那个值
仔细检查一下 $_POST['s'] 是不是那个值 我对过的没错阿。。。我在BAE试的。。一直不明白为什么。。。
你不如用 var_dump() 看看是否包含了空格换行什么的
你不如用 var_dump() 看看是否包含了空格换行什么的
没有的。。而且我也用trim()过滤了的说。。你能不能帮我看看呢。http://hole.icnu.me/t1.php
我复制他的var_dump()输出的引号+值就可以是true。
自己手打引号就是false。。。这是为什么啊??
贴出你的代码,可能不是你说的原因
贴出你的代码,可能不是你说的原因
t.php的代码。。
<?phpecho $_POST['set'].'<br>';var_dump($_POST['set']);if($_POST['set']=="f45918a75f152c9ce0b58043d5e5d7f22358665c")echo 'qw';?>
就是if里面那个双引号手打就false。。不知为什么。。。
http://hole.icnu.me/t1.php 这里post到t.php
贴出你的代码,可能不是你说的原因
应该是编码问题了。转换编码可以了。。
贴出你的代码,可能不是你说的原因
应该是编码问题了。转换编码可以了。。
错了错了。。。我也不知道为什么了。。。
我要重新描述一下了。。。
sha1加密后的字符应该是40个的
post过来后的怎么就变成43个字符了。。。?
在后面的页面重新加密的也是40个字符的。。
但是如果直接把指针指定一个那个加密后的字符串也是43个字符。。。
为什么?
var_dump()post过来的数据
string(43) "?356a192b7913b04c54574d18c28d46e6395428ab"
var_dump(sha1('1'))
string(40) "356a192b7913b04c54574d18c28d46e6395428ab"
var_dump('356a192b7913b04c54574d18c28d46e6395428ab')
string(43) "?356a192b7913b04c54574d18c28d46e6395428ab"
你 echo pack('H*', $_POST['set']); 看一下结果
你 echo pack('H*', $_POST['set']); 看一下结果
不好意思,我弄错了!
这样:
print_r(unpack('H*', $_POST['set']));
不好意思,我弄错了!
这样:
print_r(unpack('H*', $_POST['set']));
Array ( [1] => efbbbf33353661313932623739313362303463353435373464313863323864343665363339353432386162 )
Array ( [1] => efbbbf33353661313932623739313362303463353435373464313863323864343665363339353432386162 )
这个 efbbbf 是 utf-8 的 BOM 头
你去掉相关文件的 BOM 头就可以了
Array ( [1] => efbbbf33353661313932623739313362303463353435373464313863323864343665363339353432386162 )
这个 efbbbf 是 utf-8 的 BOM 头
你去掉相关文件的 BOM 头就可以了
谢了~~

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Alipay PHP...

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
