How to compare two integer passwords using array

Aakarsh:
I should use a switch statement for that?
Another problem. The Program doesn't wait for me to input the characters. It starts printing access denied as soon as I receive the otp. Should I use a delay?

try something like this:

/* @file HelloKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates the simplest use of the matrix Keypad library.
|| #
*/
#include <Keypad.h>

char* storedPassword = "5432";

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
  Serial.begin(9600);
}
  
void loop()
{
  if (char* enteredPassword = lookForPassword(keypad))
  {
    Serial.println(enteredPassword);
    if (strcmp(enteredPassword, storedPassword) == 0)
    {
      Serial.println(F("SUCCESS"));
    }
    else
    {
      Serial.println(F("EPIC FAILURE"));
    }
  }
}

char* lookForPassword(Keypad& kpd)
{
  static char password[5];
  static int idx = 0;
  if(char key = kpd.getKey())
  {
    if (key = '#')
    {
      idx = 0;
      return password;
    }
    if (isDigit(key))
    {
      password[idx++] = key;
      password[idx] = '\0';
      if (idx > 3)
      {
        idx = 0;
        return password;
      }
    }
  }
  return nullptr;
}