Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: C/C++ newb program(need help)

  1. #11
    Senior Member
    Join Date
    Jun 2003
    Posts
    236
    (in a nut shell):
    a caeser cipher is just a simple form of encryption. Basically its just what you have. You have text which is called 'plain text' and you apply a shift of N characters then you get the enciphered text which you send to someone who then applies -N to get the plain text back.

    so did that solve your problem?
    That which does not kill me makes me stronger -- Friedrich Nietzche

  2. #12
    Well, from looking at your work why are you using c and c++ statements. I would suggest either using one or the other. the cin statement in C++ is the equal to a scanf in C. Is this a C program or a C++ program. You seem very

    1) If this is a C++ app then use C++ header files ex: #include <iostream>
    the dot h at the end of the header files states that it's a C header file C++ header files don't
    have an extension.

    2) That's the reason it's not working you have C++ statements inside a C program
    cout is a C++ statement and is the same as a printf in C

    Hope this helps

    a cesear cipher is a cipher that shifts the letters down a number of spaces ABCD for example shift a lets say three spaces it would then be a D. So every occurence of the letter A would be replaced with a letter D and so on etc.........

    Good try though but at first glance I would say you found it in a cracker jack box and wonders why it doesn't work

  3. #13
    Senior Member
    Join Date
    May 2002
    Posts
    344
    i agree with phaza but if you just use #include <iostream> (because you want to write all your code in C++) make sure your next line or something is using namespace std; Anyways you should just stick with one programming language throughout your program there is a difference between C and C++. You can still type #include <iostream.h> in a C++ program, but it is better to do it like this:
    Code:
    #include <iostream>
    using namespace std;
    
    int main (void)
    {
           using std::cout;
           using std::endl;
          std::cout << "1 4/|\ 4 1337 |>r0gr4m3r" << std::endl;
          return 0;
    }
    you dont need to do the std::cout or std::endl stuff because when you type in using namespace std; you are using a using directive (kinda funky sounding)...Anyways, thought i might just teach you a little bit of C++ while we are talking about differences between C and C++
    Support your right to arm bears.


    ^^This was the first video game which i played on an old win3.1 box

  4. #14
    my thoughts too.

    yeah by the way why is this thread here it's not security related

  5. #15
    Junior Member
    Join Date
    May 2002
    Posts
    15
    I saw your code. Lot of variables used. Some lines can be cut down.But for timebeing let us have the same and discuss.Have you noticed this in your code;

    printf("%d ", inputChar[e] + mod);

    You are adding the char with a value but this affects only the display. The value stored in the array will not get changed to the sum.

    for example: if I enter 'a' and mod as 20- it prints as 97+20=117 but still the value of the array remains only 97. it should be changed to 117 which only will then deduct the mod while you decode. Or else you will not get the required answer.

    Have you heard of cryptography? It means translating plain text into scrumbled text in order to make the text unintelligible to unauthorised persons who view it. By the example encoding and decoding your objective may be that.

    "Ceaser" is said to be the first in the list of using cryptography-so his algorithm of crytography is said to be 'Ceaser Cipher'. Nothing to worry. You have got many new algo. now. You can find more information about these in our dicussion forum or in google.

    Chokks

  6. #16

    OK

    Ok, well..... First.... the reason it is in here and it isn't security related is because a guy I met said that I should go here if I have questions with programming and stick in the forum. Even though it's security related I thought that you might be able to help.
    Second... as for the switching between printf and scanf, I think I finally got that out of my system, lol I was just doing it with whichever one I felt like typing at that moment.
    umm....
    Also the reason why I just have it printf("%d", inputChar[e]+mod); is because I don't need it later. I guess if I needed it later then I could have put it into the array, but I don't so yea.....
    Ok, but yea i've gotten the program to work, I took and went through all the steps and applied messages to see if they were working, and I figured out it wasn't displaying right.. it was receiving the numbers ok and translating them, just not displaying them. So I got that done, but if you want to you can try it at:
    http://home.comcast.net/~dwcnmv/Encoder.exe

    Yea, this whole program was just practice, i've read a beginner C book and I am running on just that, so I need to find some more books.

    I think now I am going to try and make something harder, what is another simple type of encryption (I say simple cause I could probably write something to break the first one, lol), but yea what is another simple type of encryption?(that I could do in C++)

    Was also thinking of making a binary translator, but it makes it really hard because you can't copy out of the command prompt if they are big outputs that you give to someone.
    --------------------------------------------------------------------
    E, the modern pi.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •