PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Fri Jul 20, 2007 5:06 am
Hi,
I have encoded a string in the following way:
Code: Select all
$enc_str= base64_encode(bin2hex($str));
My question is, how do I decode it so that I get the original string?
I know about base64_decode(), but this only decodes base64. What about bin2hex()?
Any suggestions?
stereofrog
Forum Contributor
Posts: 386 Joined: Mon Dec 04, 2006 6:10 am
Post
by stereofrog » Fri Jul 20, 2007 5:17 am
to revert bin2hex use pack("H*", ...)
MalikBB
Forum Newbie
Posts: 11 Joined: Fri Jul 20, 2007 4:34 am
Contact:
Post
by MalikBB » Fri Jul 20, 2007 5:20 am
*The difficult way*
in first - base64_decode()
then - hexdec() - converting to normal numbers
and - decbin()
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Fri Jul 20, 2007 5:49 am
Thanks everyone.
I went with Vloka's. Cheers.
Wherever it has gone!!!
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Fri Jul 20, 2007 5:51 am
aceconcepts wrote: went with Vloka's..
which I deleted because it was exactly the same as stereofrog's
aceconcepts
DevNet Resident
Posts: 1424 Joined: Mon Feb 06, 2006 11:26 am
Location: London
Post
by aceconcepts » Fri Jul 20, 2007 7:26 am
Fair enough.