Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-23-2009, 02:44 PM   PM User | #1
testware
New Coder

 
Join Date: Oct 2009
Location: In a little room all alone with a kickass computer :D
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
testware can only hope to improve
Encryption help in C++

I'm using a method of half for encrypting simple text:

Code:
char txt[100],txtc[100];
strcpy(txt,"HELLO");

txtc[0]=txt[0];
for(i=1;txt[i]!=0;i++)
{
   if(txt[i-1]%2==1)
      txt[i-1]+=1;
   txtc[i]=(txt[i-1]/2)+(txt[i]/2);
}
Now assuming that this code would be decrypted in a logical way, can you tell me why do I encounter segmentation fault while the code is being processed?

And can someone say why my reputation is negative?? :|

Last edited by testware; 11-23-2009 at 08:05 PM.. Reason: resolved on my own
testware is offline   Reply With Quote
Old 11-23-2009, 03:22 PM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Quote:
Originally Posted by testware View Post
Now assuming that this code would be decrypted in a logical way, can you tell me why do I encounter segmentation fault while the code is being processed?
Worked for me.

Quote:
Originally Posted by testware View Post
And can someone say why my reputation is negative?? :|
Go to the User CP, you can see your reputation score and the comments on any reputation given.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 11-23-2009, 08:02 PM   PM User | #3
testware
New Coder

 
Join Date: Oct 2009
Location: In a little room all alone with a kickass computer :D
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
testware can only hope to improve
Fixed it

Had to add a 0 to the last value:

txtc[i]=0;

Somehow that was running into an error at runtime.
testware is offline   Reply With Quote
Reply

Bookmarks

Tags
c++, encryption, method of half

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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


All times are GMT +1. The time now is 06:24 PM.


Advertisement
Log in to turn off these ads.