windows auditing
+ Reply to Thread
Results 1 to 9 of 9

Thread: My Encrypt program help

  1. #1
    Join Date
    Sep 2006
    Posts
    1,649

    My Encrypt program help

    This is a simple encrypter program I made in C++. It takes 6 single digits, and converts them to their 'char' equivelent (ASCII I think.) So if you type 6 as a digit, it would convert it to the char equivelent, which is a spade sign. I know its not much, but I seem to have problems. Here is the code. I'd appreciate it if someone helped me out. (BTW, the wait4user function isn't mine, someone else had it in their code, and i copy/pasted it)

    #include <iostream>
    #include <string.h>
    using namespace std;
    void wait4user();
    int main()
    {
    cout << "Please enter 6 digit password, and press enter after each digit\n";
    int psword[6];
    cin >> psword[*];
    cin >> psword[2];
    cin >> psword[*];
    cin >> psword[4];
    cin >> psword[5];
    cin >> psword[6];
    cout << "\n\aEncryption will now begin\n";
    char p[6];
    p[*]=psword[*]+*;
    p[2]=psword[2]+*;
    p[*]=psword[*]+5;
    p[4]=psword[4]+7;
    p[5]=psword[5]+*;
    p[6]=psword[6]+**;
    cout << "Here is your new password!\n";
    cout << p[*];
    cout << " ";
    cout << p[2];
    cout << " ";
    cout << p[*];
    cout << " ";
    cout << p[4];
    cout << " ";
    cout << p[5];
    cout << " ";
    cout << p[6];
    cout << " \n";
    cout << "Press Enter to terminate program...";
    wait4user();

    return 0;
    }

    void wait4user()
    {
    std::string response;
    std::cout << "Press Enter to continue";
    std::getline(std::cin, response);
    }


    Everytime i run it, it gets to the line saying "Encryption will now begin" but suddenly terminates.

  2. #2
    Join Date
    Jan 2005
    Posts
    623
    DO NOT COPY AND PASTE CODE!!

    I'm not a big C++ coder, I found a few potential problems with your code (depending on your compiler):

    Code:
    #include <iostream>
    Some compilers are looking for the .h extension and will give an error #include <iostream.h>

    You also created some very odd arrays:
    Code:
    psword[6]
    p[6]
    The 6 means each array is has a maximun of 6 characters but you try to manually assigned a value into the 7th position of the array. The first array value starts at position 0 not *:
    Code:
    psword[0]
    p[0]
    Its hard to critique code when its not your language but this would be the easiest way for you to perform the same task. This might not be the correct syntax for C++ but this is how I would rewrite the code:

    Code:
    #include <iostream>
    #include <string.h>
    using namespace std;
    void wait4user();
    int main()
    {
    string psword[6];
    char p[6];
    
    
    cout << "Please enter 6 digit password, and press enter after each digit\n";
    cin >> psword;
    
    cout << "\n\aEncryption will now begin\n";
    
    int salt=*
    for(i=0;i<psword.length();i++)
       {
         p[i]=int psword[i]+salt;
         salt=salt+2;   
       }
    cout << "Here is your new password!\n";
    cout << p;
    
    cout << " \n"; 
    cout << "Press Enter to terminate program...";
    wait4user();
    
    return 0; 
    }
    
    void wait4user()
    {
    std::string response;
    std::cout << "Press Enter to continue";
    std::getline(std::cin, response);
    }
    Last edited by SyntaXmasteR; 09-22-2006 at 02:12 PM.
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

  3. #3
    Join Date
    Sep 2006
    Posts
    1,649

    ?

    Why shouldn't I copy and paste code? How are you gonna see it?

  4. #4
    Join Date
    Jan 2005
    Posts
    623
    Copy and Pasters make lots of mistakes.

    Did you try the script?
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

  5. #5
    Join Date
    Sep 2006
    Posts
    1,649

    yes

    Yeah, I had to make a couple tweaks.
    Right now, I'm working on making it so whatever number you type will be turned into a random letter, because it'll be hard to make a decrypter for symbols like spades and diamonds.

  6. #6
    Join Date
    Jan 2005
    Posts
    623
    You need to write a formula before you encrypt your text. Then you reverse that formula for decryption. You write the code after you create the formulas.
    [url=http://www.syntax******.info/tools/services.php]Speed Up Windows XP[/url]
    [url=http://www.syntax******.info/tools/ip.php]Get An Ip Address[/url]
    [url=http://www.syntax******.info/tools/base_converter.php]Base Converter[/url]
    --------------------------------
    [URL=http://www.boninroad.com/syntax******/]Old Site[/URL]
    [URL=http://www.syntax******.info]Comming Soon[/URL]

  7. #7
    Join Date
    Sep 2005
    Posts
    2,050
    Quote Originally Posted by Moonbat
    Why shouldn't I copy and paste code? How are you gonna see it?
    He doesn't mean you shouldn't copy and paste code here, he means you shouldn't copy and paste other people's code into your own program. It's always best to type out code yourself so you learn from it and also see any errors it has.

  8. #8
    Join Date
    Sep 2006
    Posts
    1,649

    oh

    Oh okay, I'm just about to finish it, then i can post it up

  9. #9
    Join Date
    Sep 2006
    Posts
    1,649

    Finally done

    Here is the end result of my work (Now I'm gonna try to go backwards)
    The program asks for 6 digits 0-* for a password, then converts them to to ASCII letters, by adding 65 to their value. Here it is.

    Code:
    //Number to ASCII Letter Convertion Program: By Moonbat
    #include <iostream>
    #include <cstring>
    #include <cstdlib>
    using namespace std;
    void wait4user();
    int main()
    {
    int psword[6]; //creating array for password
    char p[6]; //creating array for new password
    int i; //counter for Second Loop
    int d; //counter for First Loop
    
    cout << "Please enter 6 numbers 0-* for a password, and press enter after each number\n";
    cin >> psword[0]; //taking values for old password
    cin >> psword[*];
    cin >> psword[2];
    cin >> psword[*];
    cin >> psword[4];
    cin >> psword[5];
    
    cout << "\n\aEncryption will now begin.\n";
    wait4user();//function to force user to press Enter
    
    for (d=0;d<65;d++)//loop, whcih will make all psword values
        {             //in the ASCII alphabet range
         psword[0]++;
         psword[*]++;
         psword[2]++;
         psword[*]++;
         psword[4]++;
         psword[5]++;
        }
        
    for(i=0;i<6;i++)//loop to convert old password to new password
       {
         p[i]= psword[i];   
       }
    cout << "\nHere is your new password!\n";
    cout << p[0];
    cout << p[*];
    cout << p[2];
    cout << p[*];
    cout << p[4];
    cout << p[5];
    cout << "\n"; 
    wait4user();
    
    return *; 
    }
    
    void wait4user()//function-NOT MINE, someone else's function
    {
    std::string response;
    std::cout << "Press Enter to continue";
    std::getline(std::cin, response);
    }

+ Reply to Thread

Similar Threads

  1. How to encrypt string in c#...
    By svr2112 in forum Security & Encryption
    Replies: 8
    Last Post: 08-29-2015, 04:04 PM
  2. how to encrypt private photos?
    By meiling277869 in forum Security & Encryption
    Replies: 5
    Last Post: 12-14-2009, 04:02 AM
  3. Need a program
    By Goem in forum Programming
    Replies: 2
    Last Post: 04-08-2008, 10:43 PM

Posting Permissions

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