Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
kjm
New Member
New Member



Joined: Jun 09, 2009
Posts: 4

PostPosted: Mon Jun 08, 2009 11:55 pm Reply with quote

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?
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sat Jun 13, 2009 4:02 pm Reply with quote

Can't say I've ever had to code to this level. Therefore, I am bumping this thread to see if we can get this noticed again.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
kjm







PostPosted: Sat Jun 13, 2009 5:43 pm Reply with quote

much obliged
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Sat Jun 13, 2009 11:58 pm Reply with quote

Are you base64_encodded the data before being sent and then unencoding afterwards?
This is definitely an area I have not played with buy it seems like an encoding/charset problem to me.
 
View user's profile Send private message Send e-mail
kjm







PostPosted: Sun Jun 14, 2009 12:07 am Reply with quote

No the remotes are just sending in hex but the socket insists on putting out an ascii interpretation. So instead of C4, for example, I get Ä
 
Guardian2003







PostPosted: Sun Jun 14, 2009 12:37 am Reply with quote

Is there any way to check that the remote is sending a single or double byte character bit?
I'm not familiar with the function you are using so I'm taking a stab in the dark here but the behavior seems to be typical of charset problems, specifically that one is dealing with the data as double byte characters and the other isn't.
Depending on the actually data you are using, you may not be able character encode, so using base64_encode in the remote before being sent should force a doublebyte hex encoding of each character which can then be unencoded and give you the same data you started with.
 
kjm







PostPosted: Sun Jun 14, 2009 12:50 am Reply with quote

In encrypted mode the remotes aren't sending characters as such but raw hexadecimal. The C4 for example arrives as 1100 0100.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©