当前位置:网站首页>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边栏推荐
- Report on the application prospect and investment potential of global and Chinese cell therapy industry 2022-2028
- Vegetables sklearn - xgboost (2)
- Is the number of indexes in a table the more the better?
- cos(a-b)=cosa*cosb+sina*sinb的推导过程
- How to deploy locally developed SAP ui5 applications to ABAP servers
- Ht7180 3.7V L 12v/2a built in MOS high current boost IC solution
- Global and China chemical mechanical polishing abrasive materials market demand outlook and investment scale forecast report 2022 Edition
- Forecast report on output demand and supply scale of global and Chinese structural ceramics market for semiconductor equipment (2022 Edition)
- Understand what MTU is
- What does cardinality mean in set
猜你喜欢

Introduction to sap ui5 tools

DataX tutorial (09) - how does dataX achieve speed limit?

General test point ideas are summarized and shared, which can be directly used in interview and actual software testing

Guess the size of the number

Gb28181 protocol -- timing

レレ / 蕾蕾

ACWING2013. 三条线

Navicat防止新建查询误删

有能力的人从不抱怨大环境!
![[road of system analyst] collection of wrong questions in the chapters of Applied Mathematics and economic management](/img/62/dab2ac0526795f2040394acd9efdd3.jpg)
[road of system analyst] collection of wrong questions in the chapters of Applied Mathematics and economic management
随机推荐
Exercise: completion
JS to determine whether an element exists in the array (four methods)
有能力的人从不抱怨大环境!
Drosophila played VR and entered nature. It was found that there were attention mechanisms and working memory. The insect brain was no worse than that of mammals
Viewing Chinese science and technology from the Winter Olympics (V): the Internet of things
@The difference between notempty, @notnull and @notblank
Preliminary practice of niuke.com (summary)
ACWING/2004. 错字
Go language library management restful API development practice
How two hosts in different network segments directly connected communicate
mysql 表查询json数据
Zero foundation wants to learn web security, how to get started?
Detailed explanation of @jsoninclude annotation in Jackson
ACWING2013. 三条线
Global and Chinese benzoic acid market competition strategy and demand scale forecast report 2022
[Suanli network] problems and challenges faced by the development of Suanli network
Brief introduction and use of JSON
Query process of MySQL secondary index
Analysis report on investment and financing status and operation benefits of global and Chinese dental industry (2022 Edition)
Global and Chinese medical protective clothing market supply and demand research and investment value proposal report 2022-2028