I know the base64_encode command but it is for binary data.
And base_convert is limited to base 36.
Any help will be appreciated.
How to convert a hex or decimal to base64
Moderator: General Moderators
- WaldoMonster
- Forum Contributor
- Posts: 225
- Joined: Mon Apr 19, 2004 6:19 pm
- Contact:
-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
- WaldoMonster
- Forum Contributor
- Posts: 225
- Joined: Mon Apr 19, 2004 6:19 pm
- Contact:
I don't think base64_encode is what you want. Base 64 encoding is used for converting binary data to string such as putting attachments in email, It doesn't do number system conversions.
You'd have to write your own function to do that conversion just curious but what characters are used for base64? upper and lowercase maybe?
You'd have to write your own function to do that conversion just curious but what characters are used for base64? upper and lowercase maybe?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
a-zA-Z0-9 and a few symbols..
to find out the exact ones:
to find out the exact ones:
Code: Select all
<?php
$stream = '';
for($x = 0; $x < 64; $x++) $stream .= chr($x);
echo base64_encode($stream);
?>-
kettle_drum
- DevNet Resident
- Posts: 1150
- Joined: Sun Jul 20, 2003 9:25 pm
- Location: West Yorkshire, England
- WaldoMonster
- Forum Contributor
- Posts: 225
- Joined: Mon Apr 19, 2004 6:19 pm
- Contact:
This is what I use now to convert hex to base64:
Code: Select all
$base64 = base64_encode(pack('H*', $hex));