473,670 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bin2hex()

nabanita
9 New Member
how does the bin2hex() function works? do it changes the original file to its equivalent hexadecimal form or it copies the file to the buffer and works with it??
In the second case, I would like to know if there is a function or a way that would convert the original file to its hexadecimal form
Apr 16 '10 #1
1 1824
Atli
5,058 Recognized Expert Expert
Hey.

The bin2hex function simply takes a string, converts it to it's hexadecimal form, and then returns the new HEX string. (The input string is not altered, unless you overwrite it with the return value, if that is what you are asking.)

To convert an entire file into it's HEX equivalent, you need to load the file into PHP, run the binary string through the function, and then save it or output it or do whatever you want done with it.

Note that a file encoded in HEX is 2x larger than it's binary form, so you may find there are better ways to do whatever it is you want to do with it. (What are you planing to do with it?)
Apr 16 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
11096
by: Ivan | last post by:
Hi, let's say that my server time is for some reason incorrect! Is there a php function that would automaticly correct that time (give or take a few minutes, hours, days...) so date() function would return real time/date!! Thanks, Ivan --
4
2596
by: Chuck Anderson | last post by:
I've read some discussions, searched Google, tried pack, unpack, bin2hex, explode, implode, and I just can't figure out how to convert this data. I am trying to read a file with the following format (two examples). 41 6D 74 72 61 6B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 75 05 1A 00 41 6D 74 72 61 6B 20 4F 6E 6C 69 6E 65 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8F 05 2B 00
0
1541
by: Carl S. in 't Veld | last post by:
I am trying to generate tiger tree hashes the same way as directconnect does, but I am failing. I checked the output from php with the reference vectors from http://www.cs.technion.ac.il/~biham/Reports/Tiger/test-vectors-nessie-format.dat and they appear to be different! echo bin2hex(mhash(MHASH_TIGER, 'abc'))."<br/>\n"; outputs f258c1e88414ab2a527ab541ffc5b8bf935f7b951c132951
10
2972
by: dave | last post by:
Hello, I'm creating a site that has several contact email addresses. These are vlid addresses, i'm wondering if i can use php to alter these addresses so that spam harvesters can't get them, yet a normal user clicking on them can? Thanks. Dave.
5
17414
by: Zulik | last post by:
Hello, I might have a bad day today but I have a byte buffer holding binary numbers. Now, I want to convert this to byte buffer with hex numbers. Is there any elegant way of doing that? Some method like: byte bin2hex(byte) {} BRs, Zulik
10
4706
by: comp.lang.php | last post by:
echo mime_content_type('/var/www/html/video/small.mov'); // 1.5mb Quicktime video returns "video/quicktime" echo mime_content_type('/var/www/html/video/huge.mov'); // 10.5mb Quicktime video returns "text/plain" Environment: PHP 5.0.4 - Windows XP --enable-mime-magic PHP 4.3.11 - Fedora Core 4 --enable-mime-magic
5
3437
by: Nel | last post by:
I am trying to find a php solution to encoding an md5 hex string into another base. Using ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890 as a characters for a base 62 i.e. A = 1 a = 27 0 = 62 00 = 3844
4
1643
by: Justin | last post by:
Hi, i need some help on this urgently... Thanx.... The situation is like this, i need to find out the way to convert Chinese characters into hexa code. but the problem is what i got from bin2hex() is not giving the desired output. below is the sample of what i want: input : 新聞首頁 output: 65B0805E99969801 (this is the output from some converter for non english language UCS) output: %e6%96%b0%e8%81%9e%e9%a6%96%e9%a0%81 (this is the...
1
4473
by: markurxn | last post by:
I need a solution to automatically change the DPI of uploaded photos from 300 to 72. I've coded this bit of script to read the 14th through 18th bit of binary data of a JPEG and update the DPI. The script below seems to be writing to the jpeg, but the afterwards, the jpeg is unreadable and when I rerun the script, it still shows the image DPI hasn't changed. Anyone have experience changing DPI of an image? <?php $filename =...
3
2672
by: JimmyR.com | last post by:
I have a binary file which only has 4 bytes "FFFFFFEE". I just want to put it in a variable equaling 4294967278. How I've failed so far: <? $foo= bin2hex(file_get_contents('testplz.bin'));
0
8469
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8903
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8592
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7419
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6213
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5684
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2800
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2042
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.