Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 29th, 2006, 1:55 PM   #1
Druid
Programmer
 
Join Date: Mar 2006
Posts: 40
Rep Power: 0 Druid is on a distinguished road
Passing encrypted string through socket, weird behavior?

I am writing a client/server application, which involves the Blowfish cipher.

I have a problem, when I send encrypted data from the client to the server...
It takes the content and reads up to a certain point then truncates it, sending the remaining data to another file.

The data is:

Quote:
xNoFZ0i7Ms9.ShUsw/AizMN.WrFS7.HKAkU14I9Y9//e89b/ZXYGm.QdveX0ds8k0/0hWdh1bnymx0GpCmT.2L5M00.lPqa1p5svP/77lNQ/v0L5J19ulpN0lEuX60svnuM0KCBot/dB05N.L9CBJ1XJGmB0rVeRn0C//rB1HZ/tX.ylHVE/2dkbc0LW0Uj/NNgxO1j2j.a.QUS9w0jPf59/WU5L8/BwZwW0IDXvt03W.gw1f53kG.ORxMU1shDlY/HiOH4.3rbjW.2CX5o./P5BA/kdIhw0Kf6lA1bLrbk0FDpDT/6yCHi/Ha..k/8sKwA.psSwo12Quet1W6VWt.1twUm1SEzJF/jujLm0z1eQ4.APDvF01j9bh0FVC.X.ExK2.1SSoXP05q0vT.XK2Jl0QQiHX.sUXjs0bKMaA1RJzXI0NO8SI/aRQfC/DcTt20GIRAj/NbpuS0B6C3X1202p7.W6NIF.
It splits at the end and puts 7.W6NIF. in another file, named 7.W6NIF.

ls -lastrb indicates there is a special character on this filename:
7.W6NIF.\012



Questions:

1) Is there a way in C++ to force the read of strings as literal, instead of being "processed".

2) Is there some character code that caused the split? The buffers appear to be fine. Why split at this position?

3) Why is there a \012 on the filename of the unwanted file?
Druid is offline   Reply With Quote
Old Dec 29th, 2006, 4:42 PM   #2
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
012 is the octal value for a line feed, could be the reason the transfer seems to be splitting.

Prior to sending and receiving the data, trim it. Make sure your buffer is large enough to hold the largest data expected.

string Trim (string str)
{
    int notwhite = str.find_last_not_of(" \t\n");
    str.erase(notwhite+1);
    return str;
}
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Dec 29th, 2006, 4:50 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I doubt that your problem is with C++, per se. Octal 012 is a newline. I'm not surprised
to find one at the end. I suggest that your problem is in the handling. You don't say
much about that (system, OS, mechanism being used to make the transfer, or write the
file). You would have more luck interpreting the contents of your string if you looked at
it in hexadecimal format. Those '.'s could be anything. If there's a Windows stream
involved, and it's in default text mode, 0x1a will behave as an end-of-file indicator.

Nice job blowing the width to hell just to preserve '.'s that aren't readable, anyway .
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
C# corruption!!! Kilo C++ 32 May 21st, 2006 8:44 PM
Need help with a JSP login site Dark95 Java 3 Apr 11th, 2006 2:01 PM
Array issues :( Alo Tsum Java 10 Nov 26th, 2005 5:45 PM
Strongly encrypted stream protocol Arevos Existing Project Development 5 Oct 30th, 2005 2:39 PM
replace space with ' * ' TecBrain C++ 15 Apr 13th, 2005 12:32 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:46 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC