|
|
|
|
4
|
![main2.png](images/main2.png)
|
4
|
![main2.png](images/main2.png)
|
5
|
![main3.png](images/main3.png)
|
5
|
![main3.png](images/main3.png)
|
6
|
|
6
|
|
7
|
-[Verano 2016 - Ive]
|
|
|
|
|
7
|
+[Verano 2016 - Ive - Coralys]
|
8
|
|
8
|
|
9
|
-Commonly, when solving a problem, we select among several choices depending on whether certain conditions are met. Computer programs are built to solve problems, so they should have a structure that allows them to make decisions and select alternatives. In C++ selections are structured using `if`, `else`, `else if` or `switch`. Relational expressions and logical operators are common when handling selection structures. In today's laboratory experience you will practice the use of some of these selection structures by completing the design of an application that determines the strength of a password.
|
|
|
|
|
9
|
+Commonly, when solving a problem, we select among several choices depending on whether certain conditions are met. Computer programs are built to solve problems, so they should have a structure that allows them to make decisions and select alternatives. In C++, selections are structured using `if`, `else`, `else if` or `switch`. Relational expressions and logical operators are common when handling selection structures. In today's laboratory experience, you will practice the use of some of these selection structures by completing the design of an application that determines the strength of a password.
|
10
|
|
10
|
|
11
|
## Objectives:
|
11
|
## Objectives:
|
12
|
|
12
|
|
|
|
|
|
14
|
2. Apply selection structures.
|
14
|
2. Apply selection structures.
|
15
|
|
15
|
|
16
|
|
16
|
|
17
|
-##Pre-Lab:
|
|
|
|
|
17
|
+## Pre-Lab:
|
18
|
|
18
|
|
19
|
Before you get to the laboratory you should have:
|
19
|
Before you get to the laboratory you should have:
|
20
|
|
20
|
|
|
|
|
|
28
|
|
28
|
|
29
|
3. Studied the concepts and instructions for this laboratory session.
|
29
|
3. Studied the concepts and instructions for this laboratory session.
|
30
|
|
30
|
|
31
|
-4. Taken the Pre-Lab quiz available in Moodle.
|
|
|
|
|
31
|
+4. Taken the Pre-Lab quiz, available in Moodle.
|
32
|
|
32
|
|
33
|
---
|
33
|
---
|
34
|
|
34
|
|
|
|
|
|
40
|
|
40
|
|
41
|
Since an official system to measure password strength doesn't exist, we will use formulas created by the passwordmeter to evaluate the general strength of a given password [1]. We recommend that you play around a bit with the application in http://passwordmeter.com so that you understand how the application you will be implementing should behave. The strength of the password will be quantified by adding points for using good techniques of password selection (like using symbols and letters), and subtracting points for using bad habits (like only using lowercase letters or consecutive symbols of the same type).
|
41
|
Since an official system to measure password strength doesn't exist, we will use formulas created by the passwordmeter to evaluate the general strength of a given password [1]. We recommend that you play around a bit with the application in http://passwordmeter.com so that you understand how the application you will be implementing should behave. The strength of the password will be quantified by adding points for using good techniques of password selection (like using symbols and letters), and subtracting points for using bad habits (like only using lowercase letters or consecutive symbols of the same type).
|
42
|
|
42
|
|
43
|
-The following tables review the added and subtracted values for various criteria in passwords:
|
|
|
|
|
43
|
+The following tables review the added and subtracted values for various criteria in passwords.
|
44
|
|
44
|
|
45
|
|
45
|
|
46
|
### Assigning points to a password
|
46
|
### Assigning points to a password
|
|
|
|
|
67
|
|
67
|
|
68
|
What follows are some additional details and examples for the criteria of **adding points**.
|
68
|
What follows are some additional details and examples for the criteria of **adding points**.
|
69
|
|
69
|
|
70
|
-1. **Number of characters**: this is the simplestcriteria. The score will be $$4$$ times the length of the password. For example, `"ab453"` has a count of $$5$$ and a score of $$4 \cdot 5 = 20$$.
|
|
|
|
|
70
|
+1. **Number of characters:** this is the simplest criteria. The score will be $$4$$ times the length of the password. For example, `"ab453"` has a count of $$5$$ and a score of $$4 \cdot 5 = 20$$.
|
71
|
|
71
|
|
72
|
-2. **Uppercase letters**: the score is $$2 \left(len - n \right)$$ if the password consists of a mix of uppercase letters **AND** at least another type of character (lowercase, digits, symbols). If not, the score is $$0$$. For example,
|
|
|
|
|
72
|
+2. **Uppercase letters:** the score is $$2 \left(len - n \right)$$ if the password consists of a mix of uppercase letters **and** at least another type of character (lowercase, digits, symbols). If not, the score is $$0$$. For example:
|
73
|
|
73
|
|
74
|
- a. the score for `"ab453"` would be $$0$$ since it doesn't have uppercase letters (the count is also $$0$$).
|
|
|
|
|
74
|
+ a. The score for `"ab453"` would be $$0$$ since it doesn't have uppercase letters (the count is also $$0$$).
|
75
|
|
75
|
|
76
|
- b. the score for `"ALGO"` would be $$0$$ since it **only** has uppercase letters (the count is $$4$$).
|
|
|
|
|
76
|
+ b. The score for `"ALGO"` would be $$0$$ since it **only** has uppercase letters (the count is $$4$$).
|
77
|
|
77
|
|
78
|
- c. the score for `"SANC8in"` would be $$2 \left(7-4\right) = 6$$ since the password has a length of $$7$$, has $$4$$ uppercase letters, and contains characters of another type (the count is $$4$$).
|
|
|
|
|
78
|
+ c. The score for `"SANC8in"` would be $$2 \left(7-4\right) = 6$$ since the password has a length of $$7$$, has $$4$$ uppercase letters, and contains characters of another type (the count is $$4$$).
|
79
|
|
79
|
|
80
|
-3. **Lowercase letters**: the score is $$2 \left(len - n\right)$$ if the password is a mix of lowercase letters **AND** at least another type of character (uppercase, digits, symbols). If not, the score is $$0$$. For example,
|
|
|
|
|
80
|
+3. **Lowercase letters:** the score is $$2 \left(len - n\right)$$ if the password is a mix of lowercase letters **and** at least another type of character (uppercase, digits, symbols). If not, the score is $$0$$. For example:
|
81
|
|
81
|
|
82
|
- a. the score for `"ab453"` would be $$2 \left(5-2\right) = 6$$ because the password has a length of$$5$$, contains $$2$$ lowercase letters, and contains characters of another type. The count is $$2$$.
|
|
|
|
|
82
|
+ a. The score for `"ab453"` would be $$2 \left(5-2\right) = 6$$ because the password has a length of$$5$$, has $$2$$ lowercase letters, and contains characters of another type. The count is $$2$$.
|
83
|
|
83
|
|
84
|
- b. the score for `"ALGO"` would be $$0$$ because it doesn't have lowercase letters. The count is $$0$$.
|
|
|
|
|
84
|
+ b. The score for `"ALGO"` would be $$0$$ because it doesn't have lowercase letters. The count is $$0$$.
|
85
|
|
85
|
|
86
|
- c. the score for `"sancochin"` would be $$0$$ because it contains **only** lowercase letters. The count is $$9$$.
|
|
|
|
|
86
|
+ c. The score for `"sancochin"` would be $$0$$ because it **only** has lowercase letters. The count is $$9$$.
|
87
|
|
87
|
|
88
|
-4. **Digits**: the score is $4n$ if the password consists of a mix of digits **AND** at least another type of character (lowercase, uppercase, symbols). If not, the score is $$0$$. For example,
|
|
|
|
|
88
|
+4. **Digits:** the score is $4n$ if the password consists of a mix of digits **and** at least another type of character (lowercase, uppercase, symbols). If not, the score is $$0$$. For example:
|
89
|
|
89
|
|
90
|
- a. the score for `"ab453"` would be $$4 \cdot 3 = 12$$ because the password contains $$3$$ digits and contains characters of another type.
|
|
|
|
|
90
|
+ a. The score for `"ab453"` would be $$4 \cdot 3 = 12$$ because the password contains $$3$$ digits and contains characters of another type.
|
91
|
|
91
|
|
92
|
- b. the score for `"ALGO"` would be $$0$$ because it doesn't have digits.
|
|
|
|
|
92
|
+ b. The score for `"ALGO"` would be $$0$$ because it doesn't have digits.
|
93
|
|
93
|
|
94
|
- c. the score for `801145555` would be $$0$$ because it contains **only** digits.
|
|
|
|
|
94
|
+ c. The score for `801145555` would be $$0$$ because it **only** has digits.
|
95
|
|
95
|
|
96
|
-5. **Symbols** The score is $$6n$$ if the password contains $$n$$ symbols. Otherwise, the score is $$0$$. For example,
|
|
|
|
|
96
|
+5. **Symbols:** The score is $$6n$$ if the password contains $$n$$ symbols. Otherwise, the score is $$0$$. For example:
|
97
|
|
97
|
|
98
|
- a. the score for `"ab453"` would be $$0$$ because it does not contain symbols.
|
|
|
|
|
98
|
+ a. The score for `"ab453"` would be $$0$$ because it does not contain symbols.
|
99
|
|
99
|
|
100
|
- b. the score for `"ALGO!!"` would be $$6 \cdot 2$$ because it contains $$2$$ symbols and contains other types of characters.
|
|
|
|
|
100
|
+ b. The score for `"ALGO!!"` would be $$6 \cdot 2$$ because it contains $$2$$ symbols and contains other types of characters.
|
101
|
|
101
|
|
102
|
- c. the score for `”---><&&”` would be $$6 \cdot 7 = 42$$ because it contains $$7$$ symbols. Note that in the case of symbols, points are given even when there aren't other types of characters.
|
|
|
|
|
102
|
+ c. The score for `"---><&&"` would be $$6 \cdot 7 = 42$$ because it contains $$7$$ symbols. Note that in the case of symbols, points are given even when there aren't other types of characters.
|
103
|
|
103
|
|
104
|
-6. **Digits or symbols in the middle** The score is $$2n$$ if the password contains symbols or digits that are not in the first or last position. For example,
|
|
|
|
|
104
|
+6. **Digits or symbols in the middle:** the score is $$2n$$ if the password has symbols or digits that are not in the first or last position. For example:
|
105
|
|
105
|
|
106
|
- a. the score for `"ab453"` would be $$2 \cdot2 = 4$$ because it contains 2 digits that are not in the first or last position, these are `4` and `5`.
|
|
|
|
|
106
|
+ a. The score for `"ab453"` would be $$2 \cdot2 = 4$$ because it has 2 digits that are not in the first or last position, these are `4` and `5`.
|
107
|
|
107
|
|
108
|
- b. the score for `"ALGO!"` would be $$0$$ because it does not contain digits or symbols in the middle, the only symbol is in the last position.
|
|
|
|
|
108
|
+ b. The score for `"ALGO!"` would be $$0$$ because it does not contain digits or symbols in the middle, the only symbol is in the last position.
|
109
|
|
109
|
|
110
|
- c. the score for `S&c8i7o!` would be $$2 \cdot 3 = 6$$ because it contains $$3$$ symbols or digits in the middle, these are `&`, 8`, and `7`.
|
|
|
|
|
110
|
+ c. The score for `S&c8i7o!` would be $$2 \cdot 3 = 6$$ because it has $$3$$ symbols or digits in the middle, these are `&`, 8`, and `7`.
|
111
|
|
111
|
|
112
|
-7. **Requisites**: The score is $$2n$$ only if the length criteria **AND** 3 or 4 of the other criteria are met, where $$n$$ is the number of *criteria* that are met. The criteria are:
|
|
|
|
|
112
|
+7. **Requisites:** The score is $$2n$$ only if the length criteria **and** 3 or 4 of the other criteria are met, where $$n$$ is the number of *criteria* that are met. The criteria are:
|
113
|
|
113
|
|
114
|
- a. The password must contain 8 or more characters of length.
|
|
|
|
|
114
|
+ a. The password must have 8 or more characters of length.
|
115
|
|
115
|
|
116
|
- b. Contain:
|
|
|
|
|
116
|
+ b. The password must have:
|
117
|
|
117
|
|
118
|
- Uppercase letters
|
118
|
- Uppercase letters
|
119
|
|
119
|
|
|
|
|
|
123
|
|
123
|
|
124
|
- Symbols
|
124
|
- Symbols
|
125
|
|
125
|
|
126
|
- Each of the items listed in part b. count as one individual criteria. For example,
|
|
|
|
|
126
|
+ Each of the items listed in part b. count as one individual criteria. For example:
|
127
|
|
127
|
|
128
|
- i. the score for `"ab453"` would be $$0$$ because the criteria for length is not met.
|
|
|
|
|
128
|
+ i. The score for `"ab453"` would be $$0$$ because the criteria for length is not met.
|
129
|
|
129
|
|
130
|
- ii. the score for `"abABCDEF"` would be $$0$$ because, despite the fact that the length criteria is met, only 2 of the 4 other criteria are met (uppercase and lowercase letters).
|
|
|
|
|
130
|
+ ii. The score for `"abABCDEF"` would be $$0$$ because, despite the fact that the length criteria is met, only 2 of the 4 other criteria are met (uppercase and lowercase letters).
|
131
|
|
131
|
|
132
|
- iii. the score for `"abAB99!!"` would be $$2 \cdot 5 = 10$$ because the length criteria and the other 4 criteria are met.
|
|
|
|
|
132
|
+ iii. The score for `"abAB99!!"` would be $$2 \cdot 5 = 10$$ because the length criteria and the other 4 criteria are met.
|
133
|
|
133
|
|
134
|
|
134
|
|
135
|
#### Subtracting points
|
135
|
#### Subtracting points
|
|
|
|
|
151
|
|
151
|
|
152
|
The following are additional details and examples of the criteria for **subtracting points**.
|
152
|
The following are additional details and examples of the criteria for **subtracting points**.
|
153
|
|
153
|
|
154
|
-1. **Only letters**: The score is $$-len$$ for a password that consists of letters only, otherwise it is $$0$$. For example,
|
|
|
|
|
154
|
+1. **Letters only:** The score is $$-len$$ for a password that consists of letters only, otherwise it is $$0$$. For example:
|
155
|
|
155
|
|
156
|
- a. the score for `"ab453"` would be $$0$$ since it contains letters and numbers.
|
|
|
|
|
156
|
+ a. The score for `"ab453"` would be $$0$$ since it contains letters and numbers.
|
157
|
|
157
|
|
158
|
- b. the score for `"Barrunto"` would be $$-8$$ since it only contains letters and its length is $$8$$.
|
|
|
|
|
158
|
+ b. The score for `"Barrunto"` would be $$-8$$ since it only contains letters and its length is $$8$$.
|
159
|
|
159
|
|
160
|
-2. **Only digits**: The score is $$-len$$ for a password that consists of digits only, otherwise it is $$0$$. For example,
|
|
|
|
|
160
|
+2. **Digits only:** The score is $$-len$$ for a password that consists of digits only, otherwise it is $$0$$. For example:
|
161
|
|
161
|
|
162
|
- a. the score for `"ab453"` would be $$0$$ since it contains only letters and numbers.
|
|
|
|
|
162
|
+ a. The score for `"ab453"` would be $$0$$ since it contains only letters and numbers.
|
163
|
|
163
|
|
164
|
- b. the score for `”987987987”` would be $$-9$$ since it contains only digits and its length is $$9$$.
|
|
|
|
|
164
|
+ b. The score for `"987987987”` would be $$-9$$ since it contains only digits and its length is $$9$$.
|
165
|
|
165
|
|
166
|
-3. **Consecutive uppercase letters**: The score is $$-2n$$ where $$n$$ is the number of uppercase letters that follow another uppercase letter. For example,
|
|
|
|
|
166
|
+3. **Consecutive uppercase letters:** The score is $$-2n$$ where $$n$$ is the number of uppercase letters that follow another uppercase letter. For example,
|
167
|
|
167
|
|
168
|
a. the score for `"DB453"` would be $$-2 \cdot 1 = -2$$ since it only contains one uppercase letter (`B`) that follows another uppercase letter.
|
168
|
a. the score for `"DB453"` would be $$-2 \cdot 1 = -2$$ since it only contains one uppercase letter (`B`) that follows another uppercase letter.
|
169
|
|
169
|
|
170
|
b. the score for `"TNS1PBMA"` would be $$-2 \cdot 5 = -10$$ since it contains 5 uppercase letters (`N`, `S`, `B`, `M`, `A`) that follow another uppercase letter.
|
170
|
b. the score for `"TNS1PBMA"` would be $$-2 \cdot 5 = -10$$ since it contains 5 uppercase letters (`N`, `S`, `B`, `M`, `A`) that follow another uppercase letter.
|
171
|
|
171
|
|
172
|
-4. **Consecutive lowercase letters**: The same as for criteria #3 but for lowercase letters.
|
|
|
|
|
172
|
+4. **Consecutive lowercase letters:** The same as for criteria #3, but for lowercase letters.
|
173
|
|
173
|
|
174
|
-5. **Consecutive digits**: The same as for criteria #3 but for digits.
|
|
|
|
|
174
|
+5. **Consecutive digits:** The same as for criteria #3, but for digits.
|
175
|
|
175
|
|
176
|
|
176
|
|
177
|
---
|
177
|
---
|
|
|
|
|
201
|
|
201
|
|
202
|
In this laboratory experience you will practice the use of mathematical expressions and selection structures to compute the score for the strength of a password combining the points for the individual criteria.
|
202
|
In this laboratory experience you will practice the use of mathematical expressions and selection structures to compute the score for the strength of a password combining the points for the individual criteria.
|
203
|
|
203
|
|
204
|
-Your task is to complete the design of the application to measure the strength of a password. When done, you will obtain a simplified version of the application in http://www.passwordmeter.com/. Since there isn't an official system to measure passwords, the formulas created by "passwordmeter" will be used to evaluate the general strength of a given password. The application will allow users to enter a password and calculate its strength using a series of rules.
|
|
|
|
|
204
|
+Your task is to complete the design of the application to measure the strength of a password. When done, you will obtain a simplified version of the application in http://www.passwordmeter.com. Since there isn't an official system to measure passwords, the formulas created by "passwordmeter" will be used to evaluate the general strength of a given password. The application will allow users to enter a password and calculate its strength using a series of rules.
|
205
|
|
205
|
|
206
|
The strength of the password will be quantified by adding points for using good password selection techniques (like combining symbols and letters) and subtracting points for using bad habits (like using only uppercase letters or consecutive symbols of the same type). Your program will analyze the password given by the user and use the criteria in the tables presented above to compute a score for the password's strength.
|
206
|
The strength of the password will be quantified by adding points for using good password selection techniques (like combining symbols and letters) and subtracting points for using bad habits (like using only uppercase letters or consecutive symbols of the same type). Your program will analyze the password given by the user and use the criteria in the tables presented above to compute a score for the password's strength.
|
207
|
|
207
|
|
|
|
|
|
247
|
void setCRITERIA(int count, int score) ;
|
247
|
void setCRITERIA(int count, int score) ;
|
248
|
```
|
248
|
```
|
249
|
|
249
|
|
250
|
-where CRITERIA should be replaced by the criteria that is being evaluated. Observe that the function requires two arguments: the **count** that is the amount of characters that meet the criteria and the **score** that is the calculation that you will implement following the tables presented above. For example,
|
|
|
|
|
250
|
+where CRITERIA should be replaced by the criteria that is being evaluated. Observe that the function requires two arguments: the **count**, that is the amount of characters that meet the criteria, and the **score**, that is the calculation that you will implement following the tables presented above. For example:
|
251
|
|
251
|
|
252
|
```
|
252
|
```
|
253
|
count = pass.length() ;
|
253
|
count = pass.length() ;
|
|
|
|
|
340
|
|
340
|
|
341
|
### Exercise 4 - Determine and display the password's strength
|
341
|
### Exercise 4 - Determine and display the password's strength
|
342
|
|
342
|
|
343
|
-The password is entered in the top section of the graphical interface. The user will input the password in the top section of the graphical interface. Below appears the *report* that contains the different criteria, the count for each criteria, and the individual score for the criteria. This report will be updated as the user inputs the password's characters. The total score will be the sum of all of the points (addition and subtraction) of the individual criteria.
|
|
|
|
|
343
|
+The user will input the password in the top section of the graphical interface. Below appears the *report* that contains the different criteria, the count for each criteria, and the individual score for the criteria. This report will be updated as the user inputs the password's characters. The total score will be the sum of all of the points (addition and subtraction) of the individual criteria.
|
344
|
|
344
|
|
345
|
Based on the total score, the program will classify the password's strength as follows:
|
345
|
Based on the total score, the program will classify the password's strength as follows:
|
346
|
|
346
|
|
|
|
|
|
361
|
|
361
|
|
362
|
## Deliverables
|
362
|
## Deliverables
|
363
|
|
363
|
|
364
|
-Use "Deliverable" in Moodle to upload the `readpassword.cpp` file that contains the code with the computation for the score of the individual criteria, the final score, the function calls to update the graphical interface, the password's classification and the display functions. Remember to use good programming techniques, include the name of the programmers involved, and to document your program.
|
|
|
|
|
364
|
+Use "Deliverable" in Moodle to upload the `readpassword.cpp` file that contains the code with the computation for the score of the individual criteria, the final score, the function calls to update the graphical interface, the password's classification and the display functions. Remember to use good programming techniques, by including the name of the programmers involved, and documenting your program.
|
365
|
|
365
|
|
366
|
|
366
|
|
367
|
|
367
|
|