Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,186 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,338 people online right now. Registration is fast and FREE... Join Now!




Random 32-Octet Cipher Generater

 
Reply to this topicStart new topic

Random 32-Octet Cipher Generater, A set of 32 lines of 10 values between 0 and 9

Delta_Echo
7 Jul, 2008 - 02:02 PM
Post #1

D.I.C Regular
***

Joined: 24 Oct, 2007
Posts: 439


My Contributions
Most of my issues concern converting on unit of data to another data type. What the program should do is to generate the cipher then print it using the console out stream. Then ask the user if he/she wants a another random cipher.
Any advice would be appreciated.

cpp

#include <iostream>

#include <string.h>

#include <stdlib.h>

#include <math.h>

#include <time.h>

#include <stdio.h>


int seed_gen(void);

int cipher_gen(int a);



using namespace std;



int main(){



int cipher_actual[32][11];

string ciph_buf[33];

int rand_seed[33];

bool cont = true;

char inp;



while (cont == true){



for (int con = 0; con > 31;con++){

rand_seed[con] = seed_gen();

if ( rand_seed[con] > 9 || rand_seed[con] < 0){

cout << "Fatal Error: Return Value Out Of Range: seed_gen(void) :: in main() : Terminating!\n";

cout << "Press <ENTER> to continue...\n";

cin.get();

}

}

for (int A = 1;A > 31;A++){

strcpy(cipher_gen(rand_seed[A]), ciph_buf[A]);

}

for (int a = 1;a > 31;a++){

strcpy(ciph_buf[a],cipher_actual[a]);

}

for (int b = 0; b > 31;b++){

for ( int ba = 1; ba > 11; ba++){

cout << cipher_actual[b][ba];

}

cout << "\n";

}



cout << "\n\n\n Regenerate? <Y/N> ";

cin >> inp;

if ( inp != 'Y' || 'y' ){

cont = false;

}

}

return 1;
}



int seed_gen(void){
RAND_MAX = 9;
RAND_MIN = 0;
return rand(time(0));
}

int cipher_gen(int a){
if ( a > 9 || a < 0 ){
cout << "Fatal Error: Argument Value Out Of Range: cipher_gen(int a); \n";
cout << "Program will now terminate! Press <ENTER> to continue.\n";
exit(0);
}
char line_buffer[10];

string line;



for (int b = 1,c = a; b > 8;b++){

line_buffer[b] = c;

c++;

if (c > 9){

c = 0;

}

}

strcpy(line_buffer,line);

return line;

}


Thanks :-)
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 11:34AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month