Encryption in C++ or BASIC
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Encryption in C++ or BASIC

  1. #1
    Junior Member
    Join Date
    Jun 2003
    Posts
    13

    Encryption in C++ or BASIC

    Hey, I'm new to programming, and I know a little about basic, and a minimal amount about C++. I was wondering if anyone could explain the steps needed to be taken for writting an encryption program. If someone would like to talk to me via email or aim, I'd be really grateful, just because I don't think many people will post here... But thanks for any posts
    -0ri0n
    With what weapons World War Three will be fought, I do not know, but World War Four will be fought with sticks and stones.
    -Albert Einstein

  2. #2
    Banned
    Join Date
    Mar 2002
    Posts
    594
    I don't know C++ or BASIC that well but it would all depend on what kind of encryption you would want. Encryption could be a slight change (moves every letter up by 1, "a" would change to "b") or it could follow a specific algothrim that depends on many variables (i.e time, amount of letters, etc.).

    Well, I'll write a quick and very simple encrytion program in C++ below:
    (I apologize for any errors, I haven't programed in well over six months.)

    #include <iostream.h>

    int main()
    {

    // Bad programming skills will show... must be a 10 character password.

    char password[10];
    char encrypted[10];
    cout << "Enter the password: ";
    cin >> password;

    // Time for encryption!

    for( int x = 0; x < 10; x++)
    {
    encrytped[x] = password[x] + 1;
    }

    // Display encrypted password!

    cout << "Your encrypted password is: " << encrypted << endl;

    return 0;
    }

    Again I want to emphasize that the program above may have errors and may be quite lame but that could be a simple encrytion program that changes every letter by 1.

    As for the steps for writing an encryption program, I would imagine that they would be close to something as follows:

    1) Identify cause (simple encryption or CIA level).
    2) Form an algothrim that supports cause.
    3) Write the program.
    4) Ask people to test the program.
    5) Encrypt some text and see if t works.

    Hope this helps!

    - Cheers,
    jag291

  3. #3
    Banned
    Join Date
    Jul 2002
    Posts
    877

    Re: Encryption in C++ or BASIC

    Originally posted here by 0ri0n
    just because I don't think many people will post here... But thanks for any posts
    -0ri0n
    Your kidding me right? This has to be like one of the most active bullitin boards I've seen on the WWW.

    Ok encription.... ehhh I haven't fooled with that much but I know that in VB you can use Xor to perform an operation on two numbers, thus returning a value that can be used to encript / decrypt some text & (ect).

    (Example) Lets do simple math. 69 Xor 50 returns to the value of 119. Chr$(69) can return it into ascii. Then you can use Use Asc("69") then it can be used to turn it back into (ascii basicly known as "letters & stuff").

    Ok so my example is very short and kinda lame but its hard to code things off the top of your head I hope it'll help though.

  4. #4
    Banned
    Join Date
    Mar 2002
    Posts
    594
    Forgot to add that this is in the wrong forum... it should be programming security.

  5. #5
    Junior Member
    Join Date
    Jun 2003
    Posts
    13
    thanks for the replies thus far. And i meant I wasn't expecting people to post back on this thread. But i guess i was wrong GOD BLESS YOU ALL!!
    With what weapons World War Three will be fought, I do not know, but World War Four will be fought with sticks and stones.
    -Albert Einstein

  6. #6
    Member
    Join Date
    Aug 2001
    Posts
    31
    and dont forget that most encryption algorithms are language independent. that is, the rsa encryption algorithm (for example) can be implemented equally well in java, c, c++, probably basic too. the choice of language depends on platform, use, familiarity, etc.

    just my $.02 worth...

  7. #7
    I would say that if you wanted to created your own encryption algorithm, you might want to get a little more advanced. The post before this were very good at explaining the purpose of encryption. First, what are you encrypting, password? Partitions? Next, once the user has 'entered' the data, how will the program twist and turn it , and then turn it and twist it back. Turn it into source and you've got you algorithm. God Speed.

    Scatman
    If the scatman can do it so can you.

  8. #8
    Member
    Join Date
    Feb 2002
    Posts
    84
    Just learn some basics of programming, programming is not difficult I did it when I was twelve. For writing an encryption program you'll need to understand how encryption works. More information about encryption >> http://computer.howstuffworks.com/encryption.htm

    After reading all this information all you have to be is a little bit creative. Just like the people of the CIA and KGB.

    Good luck...
    [shadow]OpenGL rules the game[/shadow]http://www.AntiOnline.com/sig.php?imageid=499

  9. #9
    Junior Member
    Join Date
    Jan 2003
    Posts
    6
    better u`ll try 2 program tht in pearl or C. C++ is also okay. u must find them in bruce shinrer`s book 4 cryptography....u`ll learn lotz...
    |\\|e0

  10. #10
    Senior Member
    Join Date
    Oct 2001
    Posts
    786
    I have written some simple encryption programs, and have had my fair share of errors in them. If you check out http://www.antionline.com/showthread...543#post612368 , you can see links to my encryption program. It is written in Javascript/HTML, so it shouldn't be too difficult to figure out, despite my lack of comments.

    Basically, here is what you need to do to make a XOR based encryption program...

    * Make sure you have your headers, main function set up, etc...
    1) Make 3 character arrays with same length of your choice ( char key[500], plaintext[500], ciphertext[500]; )
    2) Prompt user for a Key ( cin>>key; )
    3) Prompt user for text to encrypt ( cin>>plaintext; )
    4) Encrypt plaintext and key together with a loop ( for(int i=0;i<500;i++)
    ciphertext[i]=plaintext[i]^key[i];
    5) Display ciphertext/encrypted/XORed output ( cout<<ciphertext; )

    Those steps above would result in a program similar to this:

    #include <iostream.h> // your header(s)

    // main function
    int main(void)
    {
    char key[500], plaintext[500], ciphertext[500]; // declare variables

    cout<<"What is your key? "; // display message/prompt
    cin>>key; // get the key from the user

    cout<<"\nPlease type your message below:\n"; // display message/prompt
    cin>>plaintext; // get the message to encrypt from the user

    // now, let's encrypt
    for(int i=0; i<500; i++)
    ciphertext[i]=plaintext[i]^key[i]; // this is our XOR encryption saved into the ciphertext variable

    cout<<"\nHere is your message when it is XORed:\n"<<ciphertext; // display the message

    return 0; // exit main function with code 0 (usually no errors)
    }

    Many encryption programs need a decryption program to be useful. Notice I didn't say ALL... Anyways, the beauty of XOR-based encryption is that it can encrypt and decrypt. You just have to give it the right values. By using XOR, we don't need a seperate encryption and decryption function or a whole other program which can complicate things. If you look a tjaguar291's program, it only encrypts. To decrypt, you have to change it to subtract 1, and then give the program the encrypted password. By using XOR, you use the same key, but change the other two around.

    For example, play with the values below:
    key: 123
    plaintext: abc
    ciphertext: PPP


    If you search AO, you might come across another encryption program I wrote. It shows how using seperate functions to encrypt/decrypt can create errors. If you read through (same link as above)http://www.antionline.com/showthread...hreadid=241543 you will see that Pecosian found an error in my code that existed for 1 year! BTW, you can check out that program and see how much more complex it is, especially without the comments...

    BTW, if you even read this far... good luck in your adventures in programming and cryptography


    -Tim_axe

Posting Permissions

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