Encryption
Results 1 to 7 of 7

Thread: Encryption

  1. #1

    Encryption

    A Simple Encryption Alogrithm

    Lets Take an Example, you want to send a confidentail message to your cousin over the internet.In other

    words, you donot want anyone who might intercept the message to be able to read it.To protect the message you send, you will

    encrypt ot encipher the message.


    Now Here, i have given out the source code, which implements a similar cryptographic model.



    #include <string>

    #include <cstdio>

    #include <iostream>

    #include <fstream>


    using namespace std;

    char *strencrypt(char *source)
    {
    char *original=source;

    while (*source) {

    *source=*source+3;

    source++;

    }


    char *strdecrypt(char *source)
    {

    char *orginal=source;

    while (*source) {

    *source = *source -3;
    source++;

    }

    return(orginal);
    }


    int main()

    {

    char linein[81],converted[81];
    int encryptdecrypt=1;

    int i;
    ifstream in, inclear;

    cout<< "Enter 1 to encrypt , 2 to devrypt: ";

    cin>>encryptdecrypt;

    if (encryptdecrypt == 1)
    in.open("test-enc.txt");


    else

    in.open("test-dec.txt");

    if(!in) {

    cout<< "Cannot open File." << endl;
    return (1);

    }

    while (!in.eof()) {
    for(i=0;i<80 && !in.eof(); i++)
    in.get(linein[i]);

    linein[i]=NULL;

    if(encryptdecrypt == 1)

    strcpy(converted, strencrypt(linein));

    else

    strcpy(converted, strdecrypt(linein));

    cout << converted <<endl;
    }

    in.close();

    cout<<endl<<endl;
    if(encryptdecrypt == 1)
    inclear.open("test-enc.txt");
    else

    inclear.open("test-dec.txt")

    if(!inclear) {

    cout<< "cannot open file." <<endl;

    return (1);

    }

    while (!inclear.eof()) {

    for(i=0;i<80 && !inclear.eof(); i++)

    inclear.get(linein[i]);

    linein[i]=NULL;

    cout<<linein<<endl;

    }

    inclear.close();

    return 0;
    }
    This is an simple encryption algorithm, i have laid out here for some new comers to encryption.

    If you any doubts you can post the question down here, i will be very happy to answers your questions/


    Inturn If this Code has helped you in any manner, It would very kind, in turn to visit my small community for Programmers

    Developers and Designers/

    http://www.httpguru.com

    Regards

    Biju

  2. #2
    Antionline Herpetologist
    Join Date
    Aug 2001
    Posts
    1,165
    No offense, but that has got to be the lamest, stupidest encryption algorithm I've ever seen. Just adding 3 to each character is NOT encryption. It was a nice enough try, but to write a real algorithm, you're going to have to study a hell of a lot more. Take a look at the gpg sourcecode to see how it's really done. http://gnu.org/gnupg . And use that if you want a decent encryption.

    Cheers,
    cgkanchi
    Buy the Snakes of India book, support research and education (sorry the website has been discontinued)
    My blog: http://biology000.blogspot.com

  3. #3
    Yes, I know this is not that good enough, even to say is weakest one.

    but those new to encrytion may get some usefull hints, that's all

    I will also produce some powerfull encryption later on, which would be tougher to break/

  4. #4
    Antionline Herpetologist
    Join Date
    Aug 2001
    Posts
    1,165
    but those new to encrytion may get some usefull hints, that's all
    No they won't. Because this is NOT encryption. Read the gnupg code. THAT is encryption.

    Cheers,
    cgkanchi
    Buy the Snakes of India book, support research and education (sorry the website has been discontinued)
    My blog: http://biology000.blogspot.com

  5. #5
    Senior Member gore's Avatar
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    7,177
    Not to be another dick in the wall, but making things look like gibberish, and Encryption are still two different things. Maybe you could redo this tutorial and add some information about the different types, how they work, and maybe what is best for each platform. Like DS3 being somewhat of a standard, and why Blowfish is a good method even though it's not compatible with crap, and then maybe add something about one time key pads being the abolsute best if imlplemented properly.

    Face it they are If you use them correctly, they are the safest, but they take a long time to generate keys. The Russians learned this when they thought "Hey, if we are low on keys, about using the exact same ones? As long as they are never used in the same area it should be OK!".... Of course that was false and they got cracked.

    Like I said there is a lot you could do to make this better.

    jklsdjnl;slvdjkvn is not encryption

  6. #6
    Just a Virtualized Geek MrLinus's Avatar
    Join Date
    Sep 2001
    Location
    Redondo Beach, CA
    Posts
    7,324
    I've moved this from Tutorials to here as it strikes me as not really being a tutorial. And biju, you're link doesn't work.
    Goodbye, Mittens (1992-2008). My pillow will be cold without your purring beside my head
    Extra! Extra! Get your FREE copy of Insight Newsletter||MsMittens' HomePage

  7. #7
    Senior Member
    Join Date
    Jul 2003
    Posts
    813
    Format your code using code tags rather than quote tags, even if I wanted to take a closer look it would hurt my eyes. Just a hint.

    This strikes me as a monoalphabetic substitution cipher. As a hint, if you wanted this to be helpful you should have included some theory about breaking that code, why it is weak etc. Just dumping a piece of code and calling it a tutorial will only get you massive amounts of negs... I'm surprised that for the while it was in Tutorials it didn't get negged intensively... it would make for a better experience for everybody if you just took a moment to look on the Tutorials menu [main page, righ side] and browse through the top-rated tuts on various subjects, see what those are about.
    /\\

Posting Permissions

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