base64_encode() & base64_decode() class?

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

Post Reply
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

base64_encode() & base64_decode() class?

Post by kaisellgren »

Hi,

I'm looking for a class that can do base64_(encode/decode). I'm not in need of the function that PHP supports. I need this for educational purposes. If anyone has any ideas about a class that can do this I would like to know about it. (or other languages than PHP).
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Re: base64_encode() & base64_decode() class?

Post by Luke »

what's wrong with the built-in functions? :?
toasty2
Forum Contributor
Posts: 361
Joined: Wed Aug 03, 2005 10:28 am
Location: Arkansas, USA

Re: base64_encode() & base64_decode() class?

Post by toasty2 »

I think he wants to learn how its done.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: base64_encode() & base64_decode() class?

Post by Chris Corbyn »

The base64 encoding specification can be found in RFC 2045. I'm sure there's a more complete specification elsewhere but there's definitely one in RFC 2045.

Nobody is likely to have written one in PHP since the functions already exist, but you can find Java implementations (which should more or less read like OO PHP).

Here's one in Java: http://www.source-code.biz/snippets/jav ... r.java.txt
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: base64_encode() & base64_decode() class?

Post by Chris Corbyn »

And here's a simpler encode-only implementation: http://www.koders.com/java/fid498747F58 ... 2433D.aspx
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: base64_encode() & base64_decode() class?

Post by kaisellgren »

The Ninja Space Goat wrote:what's wrong with the built-in functions? :?
Yes like someone said after you, I am looking for that in terms of education. I want to know how it's done.

I found a few classes that are non-PHP. It would be easier if it's PHP, but well non-PHP is still better than nothing :)

@Chris Corbyn: Thanks for the links. I'll have a look at them.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: base64_encode() & base64_decode() class?

Post by Chris Corbyn »

We have a user here called "Weirdan". He's posted base64 encoding/decoding algorithms here using JavaScript before if you find that easier to read than Java ;) It'll be in the "Code Snippets" forum if you want to search for the thread.
User avatar
kaisellgren
DevNet Resident
Posts: 1675
Joined: Sat Jan 07, 2006 5:52 am
Location: Lahti, Finland.

Re: base64_encode() & base64_decode() class?

Post by kaisellgren »

Chris Corbyn wrote:We have a user here called "Weirdan". He's posted base64 encoding/decoding algorithms here using JavaScript before if you find that easier to read than Java ;) It'll be in the "Code Snippets" forum if you want to search for the thread.
Thanks a bunch.
Post Reply