Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Constructive complements welcomed!

Name: Anonymous 2008-09-15 9:08


//============================================================================
// Name        : CakeSalter.cpp
// Author      : Anonymous
// Version     :
// Copyright   : All rights reserved
// Description : CakePHP Salt Value Creator in C++, Ansi-style
//============================================================================

#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string.h>

using namespace std;

int main()
{
//    cout << endl << (int) 'A' << " to " << (int) 'Z' << endl;
//    cout << (int) 'a' << " to " << (int) 'z' << endl;
//    cout << (int) '0' << " to " << (int) '9' << endl;

    unsigned int r = 0;
    unsigned int num_characters = 10;
    unsigned int max_num_characters = 40;
    unsigned int prefix_length = 0;
    char c = ' ';
    bool valid = false;
    time_t seconds;
    time(&seconds);//Get time
    srand((unsigned int) seconds);//seed with the time value
    string project_name = "";

    r = rand();

    cout << "Please enter prefix: " ;
    cin >> project_name;
    prefix_length = project_name.length();
    num_characters = max_num_characters - prefix_length;

    cout << "Salt: " << project_name; // prints Hi

    for (unsigned int i = 0; i < num_characters; i++)
    {
        while (!valid)
        {
            r = rand() % 123;//Get a number between 0 and 123
            if (((r >= 65) && (r <= 90)) || ((r >= 97) && (r <= 122)) || ((r
                    >= 48) && (r <= 57)))
            {
                valid = true;
                c = (char) r;
            }
            else
            {
                valid = false;
            }
        }
        if (valid)
        {
            cout << c;
            //reset valid to find us a new character
            valid=false;
        }
    }
    return 0;
}

Name: Anonymous 2008-09-15 9:17

That's great. Really.

Name: Anonymous 2008-09-15 9:20

raptop computer

Name: Anonymous 2008-09-15 9:31

Best code I've seen all morning.

Name: Anonymous 2008-09-15 9:34

>>4
Much appreciated

Name: Anonymous 2008-09-15 9:42

whats it do?

Name: Anonymous 2008-09-15 10:32

your indentation is fail

learn2K&R

Name: Anonymous 2008-09-15 10:47

your ghey & your coed is ghey bcuz i dont understand it u should use haskell like me so ur life will be better and ur not a fag then dats my constructive critism

Name: Anonymous 2008-09-15 12:04

>>cpp
>>C++

Theres your problem, use C maget.

Don't change these.
Name: Email:
Entire Thread Thread List