Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

base64_decode returns binary data

Posted on 2006-06-10
6
Medium Priority
?
396 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

636 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