FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Base64 Encoding/Decoding





yule
Hello all,

Base64 is another form of encryption but unlike MD5 encryption, base64 can encrypt data and decrypt data. This is useful for sending text or data securly to a MySQL database or whatever your sending to, then decrypting it so you can see it again. Here is how you do it and its very simple.

Encoding in Base64:
To encode or encrypt data in base64 you will use something similar to the following code.
Code:
<?php
base64_encode("Your text here");
?>

Which will give you something that looks like this.
Code:
WW91ciB0ZXh0IGhlcmUu

Decoding in Base64:
Then to decode or decrypt that same text you will do something like this.
Code:
<?php
base64_decode("WW91ciB0ZXh0IGhlcmUu");
?>


Then the text will appear exactly as it was before you encrypted it and thats it, you now know the basics of encrypting and decrypted strings in base64. Very Happy
althalus
How secure is it if all you need to do is run it backwards? Just asking Smile Seems like a bit of a wasted time to me.
izcool
I often use MD5 and Base64 methods when I secure login information inside of cookies and such.

I read online once that it **is** possible to decode MD5 strings.

http://md5.rednoize.com/

Surprised

- Mike.
snowboardalliance
izcool wrote:
I often use MD5 and Base64 methods when I secure login information inside of cookies and such.

I read online once that it **is** possible to decode MD5 strings.

http://md5.rednoize.com/

Surprised

- Mike.


Does that actually work?
Ranfaroth
althalus wrote:
How secure is it
It isn't.
Base64 is only used to convert binary datas to strings.
izcool wrote:
I read online once that it **is** possible to decode MD5 strings.
No it isn't.
Simply because MD5 is not encryption, but hashing.
That is to say : 2 differents strings can have the same MD5. Then, how to find the right one between them ?

Your site only has a huge list of couple (string, MD5 of the string), and does a simple search in this database.
Try with exotic strings and you'll see that there's no results.
lllgrklll
why ever using base64 to protect a string in the database?

Anyone can break this by guessing the encoding type. Try using mysql_encrypt / decrypt functions instead of this. It has a secret word added to the encoding. I use this functions for encrypting credit card info for instance.

P.S. Base 64 is very useful for sending attachements in email (especially for images, and exe files, and so on)
snowboardalliance
Credit Card info? Wouldn't you want to MD5 it? Because you really don't want a hacker to steal all of your customer's credit card numbers, that would be bad.
lllgrklll
Unfortunately, using md5 won't be useful, as I won't be able to decrypt it.
Keep in mind that I want to use cc info, with user confirmation of course, but without the need from user to reenter the cc.

And an important thing, if the encrypting phrase is strong enough, breaking an AES algorithm is imposible in our days.

For instance the following site is not using md5 for sure...:
https://verified.visa.com/aam/data/default/landing.aam?partner=default&resize=no
snowboardalliance
Sorry, I wasn't thinking. Yeah that makes sense.
epakli
why are you comparing php base64 with md5?
Nyasro
Thanks! for letting me konw about php base64 encode and decode
I hope I can use this function for encoding and decoding my text.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.