Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
hotspot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
briar
hotspot
Commits
5159c792
Commit
5159c792
authored
4 years ago
by
Sebastian Kürten
Browse files
Options
Downloads
Patches
Plain Diff
Avoid letters 0,O,l,I for wifi names and passwords
parent
8c2e2f46
No related branches found
Branches containing commit
No related tags found
1 merge request
!4
Avoid letters 0,O,l,I for wifi names and passwords
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/org/briarproject/hotspot/StringUtils.java
+12
-3
12 additions, 3 deletions
app/src/main/java/org/briarproject/hotspot/StringUtils.java
with
12 additions
and
3 deletions
app/src/main/java/org/briarproject/hotspot/StringUtils.java
+
12
−
3
View file @
5159c792
...
@@ -7,18 +7,27 @@ class StringUtils {
...
@@ -7,18 +7,27 @@ class StringUtils {
private
static
final
Random
random
=
new
SecureRandom
();
private
static
final
Random
random
=
new
SecureRandom
();
private
static
String
digits
=
"123456789"
;
// avoid 0
private
static
String
letters
=
"abcdefghijkmnopqrstuvwxyz"
;
// avoid l
private
static
String
LETTERS
=
"ABCDEFGHJKLMNPQRSTUVWXYZ"
;
// avoid I, O
public
static
String
getRandomString
(
int
length
)
{
public
static
String
getRandomString
(
int
length
)
{
char
[]
c
=
new
char
[
length
];
char
[]
c
=
new
char
[
length
];
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
if
(
random
.
nextBoolean
())
{
if
(
random
.
nextBoolean
())
{
c
[
i
]
=
(
char
)
(
'0'
+
random
.
nextInt
(
10
)
);
c
[
i
]
=
random
(
digits
);
}
else
if
(
random
.
nextBoolean
())
{
}
else
if
(
random
.
nextBoolean
())
{
c
[
i
]
=
(
char
)
(
'a'
+
random
.
nextInt
(
26
)
);
c
[
i
]
=
random
(
letters
);
}
else
{
}
else
{
c
[
i
]
=
(
char
)
(
'A'
+
random
.
nextInt
(
26
)
);
c
[
i
]
=
random
(
LETTERS
);
}
}
}
}
return
new
String
(
c
);
return
new
String
(
c
);
}
}
private
static
char
random
(
String
universe
)
{
return
universe
.
charAt
(
random
.
nextInt
(
universe
.
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