Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tut-5-login
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cosc360-2016
tut-5-login
Commits
bc4cbeaf
Commit
bc4cbeaf
authored
9 years ago
by
William Billingsley
Browse files
Options
Downloads
Patches
Plain Diff
Added some static methods for simple captcha processing
parent
521f1c8b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/model/Captcha.java
+57
-0
57 additions, 0 deletions
app/model/Captcha.java
with
57 additions
and
0 deletions
app/model/Captcha.java
0 → 100644
+
57
−
0
View file @
bc4cbeaf
package
model
;
public
class
Captcha
{
/**
* URLs of photos the user should select
*/
public
static
String
[]
yesPhotos
=
{
};
/**
* URLs of photos the user should not select
*/
public
static
String
[]
noPhotos
=
{
};
/**
* How many photos there are in total
*/
public
static
int
numPhotos
()
{
return
yesPhotos
.
length
+
noPhotos
.
length
;
}
/**
* The index of a random photo
*/
public
static
int
randomPhotoIdx
()
{
return
(
int
)(
Math
.
random
()
*
numPhotos
());
}
/**
* Get a photo with the specified index
*/
public
static
String
getPhoto
(
int
idx
)
{
if
(
idx
<
0
||
idx
>=
numPhotos
())
{
throw
new
IllegalArgumentException
(
"index out of range"
);
}
if
(
idx
<
yesPhotos
.
length
)
{
return
yesPhotos
[
idx
];
}
else
{
return
noPhotos
[
idx
-
yesPhotos
.
length
];
}
}
/**
* Whether a photo selected by the user was in the "yes" set
*/
public
boolean
isCorrect
(
int
idx
)
{
return
idx
>=
0
&&
idx
<
yesPhotos
.
length
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment