Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Part02
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Assessment
Part02
Commits
8982a5cb
Commit
8982a5cb
authored
Nov 26, 2018
by
neil.whitehead
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
12:23 26/11/91
parent
e9c3cf05
Pipeline
#341
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
31 deletions
+37
-31
AssessmentPartTwo.java
src/AssessmentPartTwo.java
+37
-31
No files found.
src/AssessmentPartTwo.java
View file @
8982a5cb
import
java.util.Arrays
;
public
class
AssessmentPartTwo
{
...
...
@@ -19,25 +20,21 @@ public class AssessmentPartTwo {
aWord
=
aWord
.
toLowerCase
();
//converts string to lowercase
char
chaWordArr
[]
=
aWord
.
toCharArray
();
//places string into array as ASCII chars
for
(
int
i
=
0
;
i
<
chaWordArr
.
length
;
i
++)
{
//Validation: if value is not lowercase letter (ASCII 97 - 122) then skip this iteration
if
((
chaWordArr
[
i
]
<
97
)
||
(
chaWordArr
[
i
]
>
122
))
{
continue
;
}
continue
;
//Validation: if value is not lowercase letter (ASCII 97 - 122) then skip this iteration
}
intWordScore
=
intWordScore
+
intScoreArr
[(
chaWordArr
[
i
]-
97
)];
//Char's ASCII code - 97 = Char's position in intScoreArr
}
return
intWordScore
;
}
public
B
oolean
passwordValidator
(
String
password
)
public
b
oolean
passwordValidator
(
String
password
)
{
// 04 - Password Validator
// Complete this method to validate that the String password
...
...
@@ -48,62 +45,71 @@ public class AssessmentPartTwo {
// - has at least one lower case letter, one upper case letter and a number
// - does not contain the phrases 'password' or 'passwd'
boolean
booPasswordLength
=
false
;
boolean
booPasswordChars
=
false
;
boolean
booPasswordUpper
=
false
;
boolean
booPasswordLower
=
false
;
boolean
booPasswordNum
=
false
;
boolean
booPasswordUpperLowerNum
=
false
;
boolean
booPasswordIsPassword
=
false
;
char
passwordArr
[]
=
password
.
toCharArray
();
//true == correct, false == incorrect
//Password length between 8 and 16 characters
booPasswordLength
=
((
password
.
length
()
>=
8
)
&&
(
password
.
length
()
<=
16
))
?
true
:
false
;
if
(!((
password
.
length
()
>=
8
)
&&
(
password
.
length
()
<=
16
)))
{
return
false
;
}
//Password only alphanumeric or !�$%, contains both upper, lower, and numerics
for
(
int
i
=
0
;
i
<
passwordArr
.
length
;
i
++)
for
(
int
i
=
0
;
i
>
passwordArr
.
length
;
i
++)
{
//, ,
System
.
out
.
println
(
passwordArr
[
i
]);
if
((
passwordArr
[
i
]
>=
48
)
&&
(
passwordArr
[
i
]
<=
57
))
{
booPasswordChars
=
true
;
booPasswordNum
=
true
;
}
else
if
((
passwordArr
[
i
]
>=
65
)
&&
(
passwordArr
[
i
]
<=
90
))
//65
- 90 = A -
B
else
if
((
passwordArr
[
i
]
>=
65
)
&&
(
passwordArr
[
i
]
<=
90
))
//65
to 90 = A to
B
{
booPasswordChars
=
true
;
booPasswordUpper
=
true
;
}
else
if
((
passwordArr
[
i
]
>=
97
)
&&
(
passwordArr
[
i
]
<=
122
))
// 97 - 122 = a - b
{
booPasswordChars
=
true
;
else
if
((
passwordArr
[
i
]
>=
97
)
&&
(
passwordArr
[
i
]
<=
122
))
// 97 to 122 = a to b
{
booPasswordLower
=
true
;
}
}
else
if
(
passwordArr
[
i
]
==
33
||
passwordArr
[
i
]
==
63
||
passwordArr
[
i
]
==
36
||
passwordArr
[
i
]
==
37
)
//33 = !, 63 = ?, 36 = $, 37 = %
{
booPasswordChars
=
true
;
{
}
else
else
//only runs when invalid character is identified
{
booPasswordChars
=
false
;
return
false
;
}
//FUCK SAKE. LOOK UP REGEXES.
}
}
//
if
((
booPasswordUpper
==
true
)
&&
(
booPasswordLower
==
true
)
&&
(
booPasswordNum
==
true
))
{
return
true
;
}
else
{
return
false
;
}
//str1.toLowerCase().contains(str2.toLowerCase()) if it contains Password.
for
(
int
i
=
0
;
i
<
passwordArr
.
length
;
i
++)
//FUCK SAKE. LOOK UP REGEXES.
//str1.toLowerCase().contains(str2.toLowerCase()) if it contains Password.
return
booPasswordChars
;
//for(int i = 0; i < passwordArr.length; i++)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment