views:

83

answers:

2

Hi,

I have base 64 encoded string that looks something like this.

cuVrcYvlqYze3OZ8Y5tSqQY205mcquu0GsHkgXe4bPg=

I have tried base64_decode and output is.

råkq‹å©ŒÞÜæ|c›R©6Ó™œªë´Áäw¸lø

I think I may be doing something wrong. I appreciate any help to convert base64 string to binary array.

Thanks

+1  A: 

like this

$a = base64_decode("cuVrcYvlqYze3OZ8Y5tSqQY205mcquu0GsHkgXe4bPg=");
$b = array();
foreach(str_split($a) as $c)
    $b[] = sprintf("%08b", ord($c));
print_r($b);
stereofrog
Thanks. I am trying to base64_decode($key) and create a authentication signature like this hash_hmac("sha1", $ID, base64_decode($key), true); but it is not working. Am I doing something wrong? I appreciate your help.
Nick
@Nick, i'm not quite sure what you're doing... maybe asking the service provider would be an option?
stereofrog
A: 

You already are getting binary data back from base64_decode (if the encoded data was in fact binary), only this binary data is interpreted as encoding for some text by whatever you're outputting to (browser?). A "0011010110011001" output itself would also only be text, which would be encoded using some (different) binary stream. The computer does not work with 1's and 0's internally, contrary to popular believe. If you want to visualize binary data in the form of 1's and 0's, you'll need to do the binary/text conversion yourself. Usually that's a pretty pointless thing to do, though.

You're probably already doing the right thing. Your mistake is in expecting binary data to be represented as "0100101010".

deceze