forked from ChicoState/UnitTestPractice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Password.h
51 lines (44 loc) · 1.32 KB
/
Password.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef PRACTICE_H
#define PRACTICE_H
#include <string>
#include <vector>
using std::string;
using std::vector;
class Password
{
private:
vector <string> pass_history;
public:
/*
The function receives a string counts how many times the same character
occurs at the beginning of the string, before any other characters (or the
end of the string). The function is case-sensitive so 'Z' is different than
'z' and any ASCII characters are allowed.
*/
int count_leading_characters(string);
/*
returns whether the phrase has both at least one upper-case letter and
at least one lower-case letter
*/
bool has_mixed_case(string);
/*
constructor sets the default password to "ChicoCA-95929"
*/
Password();
/*
receives a password and sets the latest in pass_history to it if and only
if it meets all criteria:
1. The password is at least 8 letters long
2. It has no more than 3 of the same leading characters
3. It has mixed case (at least one upper case and at least one lower case)
4. It was not a previous password in the history
*/
void set(string);
/*
receives a string and authenticates it against the latest password in the
pass_history, returning true for an exact match or false when it does not match
or if a password has not been set.
*/
bool authenticate(string);
};
#endif