php openssl 使用 aes256 加密数据并使用 sha256 哈希传递帮助!
openssl 只接受 sha256 哈希密码的一半$encryptedkey = openssl_encrypt($data, 'AES256', "$sha256", $raw_output = false);
哈希看起来像这样:a0461cea77b9942addee32b2265b32ebcf150426e2490810938ab47206fd320b
它只接受32个字符:a0461cea77b9942addee32b2265b32eb
我该如何解决这个问题?谢谢你!
编辑:示例:解密数据时,如果哈希值在 32 个字符后不匹配,即使错误,它仍然会解密
a0461cea77b9942addee32b2265b32ebcf150426e2490810938ab47206fd320b
a0461cea77b9942addee32b2265b32ebcf150426e24808019485b43406df3a9b
当他们不应该工作时,两者都会工作吗?
openssl only accepting half of a sha256 hashed password$encryptedkey = openssl_encrypt ($data, 'AES256', "$sha256", $raw_output = false);
hash looks like this:a0461cea77b9942addee32b2265b32ebcf150426e2490810938ab47206fd320b
its only accepting 32 characters of it:a0461cea77b9942addee32b2265b32eb
how can i fix this? thank you!
edit: example: when decrypting the data if the hash does not mach after 32 character it will still decrypt it even if its wrong
a0461cea77b9942addee32b2265b32ebcf150426e2490810938ab47206fd320b
a0461cea77b9942addee32b2265b32ebcf150426e24808019485b43406df3a9b
both will work when they shouldn't?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你应该传递原始数据,而不是它的十六进制表示。我这么说是因为 32*8=256,因此通过读取 32 个字符,该函数实际上读取 256 位。
尝试传递
pack("H*", $sha256)
而不是$sha256
。I'd guess you should pass the raw data, not an hexadecimal representation of it. I say this because 32*8=256, hence by reading 32 characters, the function is actually reading 256 bits.
Try passing
pack("H*", $sha256)
instead of$sha256
.