当前位置:网站首页>PHP converts strings to hex and hex to string - PHP convert string to hex and hex to string
PHP converts strings to hex and hex to string - PHP convert string to hex and hex to string
2022-06-25 06:37:00 【Rich in starch】
problem :
I got the problem when convert between this 2 type in PHP. stay PHP In this 2 There was a problem converting between types .This is the code I searched in google This is the code I searched in Google
function strToHex($string){ $hex=''; for ($i=0; $i < strlen($string); $i++){ $hex .= dechex(ord($string[$i])); } return $hex;}function hexToStr($hex){ $string=''; for ($i=0; $i < strlen($hex)-1; $i+=2){ $string .= chr(hexdec($hex[$i].$hex[$i+1])); } return $string;}I check it and found out this when I use XOR to encrypt. I check it and use it XOR This was discovered during encryption .
I have the string "this is the test" , after XOR with a key, I have the result in string ↑§P§P *§T§ . I have a string "this is the test" , After using a key XOR , My result is a string ↑§P§P *§T§ .After that, I tried to convert it to hex by function strToHex() and I got these 12181d15501d15500e15541215712 . after , I try to use the function strToHex() Convert it to hexadecimal , I got these 12181d15501d15500e15541215712 .Then, I tested with the function hexToStr() and I have ↑§P§P*§T§q . then , I use functions hexToStr() Tested , I have a ↑§P§P*§T§q .So, what should I do to solve this problem? that , What should I do to solve this problem ?Why does it wrong when I convert this 2 style value? Why do I switch this 2 An error occurs when a style value is ?
Solution :
Reference resources : https://stackoom.com/en/question/zZas边栏推荐
- Aviator an expression evaluation engine
- DataX tutorial (10) - hot plug principle of dataX plug-in
- Why can't GC () free memory- Why does gc() not free memory?
- 北京网上开股票账户安全吗?
- Global and China chemical mechanical polishing abrasive materials market demand outlook and investment scale forecast report 2022 Edition
- [short time energy] short time energy of speech signal based on MATLAB [including Matlab source code 1719]
- Comparison test of mono 120W high power class D power amplifier chip cs8683-tpa3116
- [Suanli network] problems and challenges faced by the development of Suanli network
- Asemi fast recovery diode us1m parameters, us1m recovery time, us1m voltage drop
- Zero foundation wants to learn web security, how to get started?
猜你喜欢
![[hand torn STL] Stack & queue](/img/db/d05c52f8e3fb0aade51460e86cf623.jpg)
[hand torn STL] Stack & queue

レレ / 蕾蕾

IQ debugging of Hisilicon platform ISP and image (1)

What is the IP address

In depth inventory: 23 vscode plug-in artifacts that improve development efficiency and aesthetics

ACWING/2004. 错字

Sleep quality today 67 points

Gb28181 protocol -- timing

Cs4344/ht5010 stereo d/a digital to analog converter

Monitoring access: how to grant minimum WMI access to the monitoring service account
随机推荐
有能力的人从不抱怨大环境!
How to deploy locally developed SAP ui5 applications to ABAP servers
Global and Chinese gallium nitride (GAN) market output value scale forecast and application prospect analysis report 2022
Introduction to sap ui5 tools
ASP. Net core - encrypted configuration in asp NET Core
Sword finger offer II 095 Longest common subsequence
Wan Yin revealed that he was rejected by MIT in this way: "the department doesn't like you". He confronted the principal and realized
DNS domain name system
cos(a-b)=cosa*cosb+sina*sinb的推导过程
[hand torn STL] Stack & queue
Cannot activate inspection type when SAP retail uses transaction code mm41 to create commodity master data?
Research Report on demand and Competitive Prospect of global and Chinese welding personal protective equipment industry 2022-2027
Understand what MSS is
[short time energy] short time energy of speech signal based on MATLAB [including Matlab source code 1719]
JD 8 fleet stores search history, deletes history, clears history (not finished)
Research Report on brand strategic management and marketing trends in the global and Chinese preserved fruit market 2022
Navicat防止新建查询误删
Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
ASP. Net core - Safety of asynclocal in asp NET Core
Cs5092 5V USB input boost two section lithium battery charging management IC, SOT23-6 miniature package