search and didnt find anything that was close to this. so my assignment is to simulate a simple authentication, where the user enters their original pin or password(numbers only). it must use arrays to assign the password a pseudo-random assignment of 1-3 for digits 0-9. after that the program clears the screen and asks the user to reenter the password using the only 1-3 according to the reference table displayed. then the program is supposed to output if the new entry was correct or not.
most of the program works logically at least but my problem is idk how to compare the stored random assignments against the original password. here's what i've got so far there's a big comment line where im having problems in the code.
[
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <time.h>
using namespace std;
void random_numbers(int random_number[]) //randomly generate numbers from 1-3 for each digit.
{
srand ( time(NULL) );
for (int i = 0; i < 10; i++)
{
random_number[i] = (rand()% 3) + 1;
}
cout << "Random #'s:\t";
for (int i = 0; i < 10; i++)
cout << random_number[i] << " ";
cout << endl << endl;
}
void password_reference()
{
cout << "Reference #'s:\t";
for ( int i = 0; i < 10; i++)
{
cout << i << " ";
}
cout << endl;
}
void pw_storage(int stored[])
{
// Input the user's entry
cout << "Please store your 8 digit password number in to program first: "<<endl;
cin >> stored[8];
// system ("cls"); //clear the screen to hide the password for security concern
}
bool isValid(int actual_PW[], int entered_PW[], int random_Nums[])
{
bool valid = false;
//*****************************This is where i'm having trouble**********************************
for (int index = 0; (!valid) && (index < sizeof(actual_PW)); index++)
{
random_Nums[index] = actual_PW[index];
if (entered_PW[index] != )
{
valid = false;
}
}
return valid;
}
int main()
{
int stored_PW[8], random_nums[10], encoded_PW[8];
bool valid = false;
pw_storage(stored_PW);
password_reference();
random_numbers(random_nums);
cout << "Enter password corrsponding to the reference table:\n";
for(int i = 0; i < 8; i++)
cin >> encoded_PW[i];
isValid(stored_PW, encoded_PW, random_nums);
if(valid == true)
cout << "Correct! You may now proceed" << endl;
else
cout << "Error, invalid password entered" << endl << "Enter your password again." << endl;
}