Forum Moderators: coopster

Message Too Old, No Replies

decoding base64 from an array

         

fintan

9:48 am on May 25, 2006 (gmt 0)

10+ Year Member



Hi I'm trying to decode base64 from a ldap query. I can print it directly from the array but I can't print it directly to a page. I've tried base64_decode() with no luck. An example of the the array is below. Any help would be apprieciated. Thanks

fintan.

Array
(
[count] => 9
[0] => Array
(
[guid] => Array
(
[count] => 1
[0] => €,ÉÃòÚ»L
)

[0] => guid
[count] => 1
[dn] => cn=,ou=,ou=,o=
)

[1] => Array
(
[guid] => Array
(
[count] => 1
[0] =>
)

[0] => guid
[count] => 1
[dn] => cn=,ou=,ou=,o=
)

[2] => Array
(
[guid] => Array
(
[count] => 1
[0] => €—œMîÔÔ‡›
)

[0] => guid
[count] => 1
[dn] => cn=,ou=,ou=,o=
)

coopster

5:04 pm on May 25, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



base64_decode() [php.net] expects a string as argument. If you are trying to decode an array it is not going to work. You need to loop through the array and decode each value.

fintan

10:55 am on May 26, 2006 (gmt 0)

10+ Year Member



Hi coopster here's what I got so far

straight from ldap: €,ÉÃòÚ»L

base64_encode: gCzJw/Ia2hG7TA==

base64_decode: €,ÉÃòÚ»L

What I'm hoping for is

hex

00 D7 8D EF 9D FA D9 11 93 B4 00 07 E9 OD A1 9E

Is there a way to change this €,ÉÃòÚ»L into the above. Thanks

fintan.

coopster

11:44 am on May 26, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



bin2hex [php.net] is my first thought but that doesn't return the hex value you have shown here.

fintan

3:06 pm on May 26, 2006 (gmt 0)

10+ Year Member



Thanks coopster think you just solved my problem. The hex is only an example.

fintan

3:26 pm on May 26, 2006 (gmt 0)

10+ Year Member



Here's a proper sample

encode: gMaqIVUg2hG7TA==
decode encode: €Æª!U Ú»L
straight: €Æª!U Ú»L
hex: 80c6aa215520da11bb4c

It's cutting it after c. There's a 00 after c that's it's not displaying.

The full hex is

80 C6 AA 21 55 20 DA 11 BB 4C 00 30 05 47 08 81

coopster

4:58 pm on May 26, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't know from where that full hex is derived but it isn't what I get. What is the starting value, before any encoding/decoding or other translation?

fintan

8:30 am on May 29, 2006 (gmt 0)

10+ Year Member



When I print out the array using print_r I get.

€Æª!U Ú»L

But It's missing a couple of charaters from the end

This is the raw format I think. It's not sorted but the systems we use treat it as the same. From what I can find it's ment to be.

raw: 21aac680-2055-11da-bb4c-003005470881

sorted: 80 C6 AA 21 55 20 DA 11 BB 4C 00 30 05 47 08 81

The 80,aa,c6 & so on do match up.

Thanks