?
Solved

base64_decode returns binary data

Posted on 2006-06-10
6
Medium Priority
?
393 Views
Last Modified: 2012-08-14
the base64_decode() returns data in binary!

ive tried to display the output from base64_decode($handshake) and i get binary??

is there someother function that can convert the decoded data in readable data so i can compare it in my code below?

<?php
$handshake = '';
$handshake = trim($_GET['handshake']);

if("xyz" == base64_decode($handshake))
      echo "Handshake OK";
else
      echo "HACKING ATTEMPT";
?>
0
Comment
Question by:ellandrd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 29

Accepted Solution

by:
TeRReF earned 1000 total points
ID: 16876868
Is it serialized perhaps? Normally the function returns the decoded string, so that's weird...
What is it you encode...
Can you show us the whole cycle? SO, both the encoding and decoding part?
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16877084
OK, example:

<?php
$str = 'secret';
$encoded_str = base64_encode($str);
if("secret" == base64_decode($encoded_str))
     echo "OK";
else
     echo "HACKING ATTEMPT";
?>

will fail as base64_decode() return binary data.  How can i decode a string encrpyted by base64?
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16877106
see another example:

<?php
$encoded_str = "KHvCoxP73EqvnVaCubzwUQ==";
echo "<p>".$encoded_str."</p>";
$decoded_str = base64_decode($encoded_str);
echo "<p>".$decoded_str."</p>";
?>

output:

KHvCoxP73EqvnVaCubzwUQ==

({£ûÜJ¯V‚¹¼ðQ

The $encoded_str value is a string encoded using a base64 algorithm sent in the URL....

 
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 16

Author Comment

by:ellandrd
ID: 16877141
fixed!
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 16877286
Well done, can you tell us how, so people with the same problem can use your solution...
0
 
LVL 16

Author Comment

by:ellandrd
ID: 16877853
i use md5 hashing instead.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question