当前位置:网站首页>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边栏推荐
- joda.time获取日期总结
- [200 opencv routines of youcans] 104 Motion blur degradation model
- Asemi fast recovery diode us1m parameters, us1m recovery time, us1m voltage drop
- Wechat applet authorization login + mobile phone sending verification code +jwt verification interface (laravel8+php)
- Cs8683 (120W mono class D power amplifier IC)
- What is VLAN
- Personal blog system graduation project opening report
- After five years of software testing in ByteDance, I was dismissed in December to remind my brother of paddling
- [kicad image] download and installation
- Cs8126t 3.1w mono ultra low EMI unfiltered class D audio power amplifier IC
猜你喜欢

ACWING/2004. 错字
![[kicad image] download and installation](/img/88/cebf8cc55cb8904c91f9096312859a.jpg)
[kicad image] download and installation

After unplugging the network cable, does the original TCP connection still exist?
![[core content and derivation] the mystery of human memory system may be just like this](/img/7c/98f27bb55a1a3b74c0ed8fd7fd2cc5.jpg)
[core content and derivation] the mystery of human memory system may be just like this

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

Cs4344/ht5010 stereo d/a digital to analog converter

Self adjustment process of MySQL index tree when adding data

Comparison test of mono 120W high power class D power amplifier chip cs8683-tpa3116

2022-02-19: fence installation. In a two-dimensional garden, there are some trees represented by (x, y) coordinates. As the installation cost is very expensive, your task is to enclose all the trees w
![[hand torn STL] Stack & queue](/img/db/d05c52f8e3fb0aade51460e86cf623.jpg)
[hand torn STL] Stack & queue
随机推荐
Methods for obtaining some information of equipment
Comparison test of mono 120W high power class D power amplifier chip cs8683-tpa3116
With a younger brother OCR, say no to various types of verification codes!
HCIP Day 16
[road of system analyst] collection of wrong questions in the chapters of Applied Mathematics and economic management
Query process of MySQL secondary index
Advantages and disadvantages of using SNMP and WMI polling
How to deploy locally developed SAP ui5 applications to ABAP servers
China rehabilitation hospital industry operation benefit analysis and operation situation investigation report 2022
2022 AI trend 8 forecast!
百度地图——入门教程
Research Report on brand strategic management and marketing trends in the global and Chinese preserved fruit market 2022
Global and Chinese benzoic acid market competition strategy and demand scale forecast report 2022
Period to string [repeat] - period to string [duplicate]
Research Report on global and Chinese vaccine market profit forecast and the 14th five year plan development strategy 2022-2028
DataX tutorial (10) - hot plug principle of dataX plug-in
Understand what MTU is
Cs8683 (120W mono class D power amplifier IC)
Are these old system codes written by pigs?
mysql 表查询json数据