C++でのユーザー登録を管理するシンプルなシステムを完成させようとしています(パスワードハッシングを使用)。私はインストラクターに必要なユーザー名とパスワードを保存する方法を考え出し、失敗した3回の試行後に誰かをロックする方法を見つけようとしています。私のコードでは、私はこれを行うために使用しようとしていたコードをコメントしましたが、私は動作するとは思わない。私は本当に3つの試行後に誰かをロックする機能を作成する方法に関する提案を感謝します。ユーザー10人分のユーザー登録プログラム
#include <iostream>
#include <string>
using namespace std;
int returnVal(char x)
{
return x - 96;
}
char usrname;
int main() {
string name[10];
int password[10];
bool status[10];
int index = 0;
for (int i = 0; i < 10; i++)
{
//int count = 0;
//for (;;)
//{
//ask_password();
//if (password == expected_password)
//break;
//count++;
//if (count == 3)
//{
// Sleep(300000); // 5 minutes = 300000 ms.
// count = 0;
//}
}
string s;
cout << "Please Enter Username " << endl << "Should you wish to stop entering user information enter 0: ";
cin >> name[index];
if (name[index] == 0) {
break;
}
cout << "Please Enter Password ";
cin >> s;
cout << "Are you a regular user or an admin? " << endl << "Enter 0 for a regular user and 1 for admin: ";
cin >> status[index];
int niffler = 0;
for (unsigned int i = 0; i < s.length(); i++)
{
niffler = niffler + returnVal(s[i]);
}
password[index] = niffler;
cout << niffler;
index++;
}
cout << "10 users have been created";
// check username array for input
// save where in the array we find the correct username
// check password
return 0;
}
ここでは宿題をしません。あなたの* fix-my-code *または* write-my-code *質問は話題にはなりません。もっと考えてください。すべての警告とデバッグ情報でコンパイルします( 'g ++ -Wall -g')。 **デバッガ**( 'gdb') –
あなたの質問を編集して、コードの書式とインデントを修正してください。 – Lundin
あなたはパスワードをチェックするコードをコメントアウトしたが、インストラクターはログイン失敗回数が3回に達した後にユーザーをロックするように(Basileと同意し、誰もあなたの宿題を望んでいない)障害をチェックするコードを提供していないときにも、どのように助けを始めようとしていますか? –