stream_socket_recvfrom problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kjm
Forum Newbie
Posts: 1
Joined: Mon Jun 08, 2009 9:42 pm

stream_socket_recvfrom problem

Post by kjm »

I've been using stream_socket-recvfrom to receive short plain text ascii packets from some internet enabled remote devices. So the letter I for example arrives as a 49 which is the ascii code for same & the socket puts out an I.
However when I set the remotes into AES encrypted mode they not only encrypt but they switch to sending in hex instead of ascii. So after the I has been encrypted it might arrive as a C4.
This is a real problem because the socket listener puts out strange characters (like Ä for C4 or ‰ for 89). If the characters are printable I can use an ascii to hex converter after the socket listener to get the original hex back but many ascii representations of hex values just won't convert back to the original hex.
So to successfully use mycrypt or similar to decode the encrypted packets I need a socket listener that can handle hexadecimal strings.
Seems simple enough but I'm stumped on how to do it. Any ideas from you learned practitioners of the art?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: stream_socket_recvfrom problem

Post by Weirdan »

I guess seeing the code along with some trace statements and what they print would be helpful. I'd recommend to base64_encode received values before printing, so original binary data could be reconstructed.
Post Reply