Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Access Check - Account manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
edugain
eduGAIN Access Check - Account manager
Commits
3faba161
Commit
3faba161
authored
7 years ago
by
Guillaume ROUSSE
Browse files
Options
Downloads
Patches
Plain Diff
more readability
parent
5c98e1c3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/AccountManager/Tools.pm
+18
-38
18 additions, 38 deletions
lib/AccountManager/Tools.pm
with
18 additions
and
38 deletions
lib/AccountManager/Tools.pm
+
18
−
38
View file @
3faba161
...
...
@@ -7,6 +7,7 @@ use Digest::SHA;
use
Digest::
MD5
;
use
Encode
;
use
English
qw(-no_match_vars)
;
use
List::
Util
qw(shuffle)
;
use
List::
MoreUtils
qw(pairwise)
;
use
MIME::
Base64
;
use
Template
;
...
...
@@ -49,49 +50,28 @@ sub sha256_hash {
# This function generates a random password
sub
generate_password
{
my
$length_of_randomstring
=
10
;
# the length of
# the random string to generate
# plusieurs tirages :
# 1-tirage des caractères obligatoires : les mettre dans un tableau
my
@uppers
=
('
A
'
..
'
N
',
'
P
'
..
'
Z
');
my
@lowers
=
('
a
'
..
'
k
',
'
m
'
..
'
z
');
my
@punctuation
=
('
:
',
'
!
',
'
?
',
'
&
',
'
$
',
'
=
',
'
-
',
'
#
');
my
@numerics
=
('
0
'
..
'
9
');
my
@rndtab
;
push
(
@rndtab
,
$uppers
[
rand
@uppers
]);
push
(
@rndtab
,
$lowers
[
rand
@lowers
]);
push
(
@rndtab
,
$punctuation
[
rand
@punctuation
]);
## Pas de caractères 8bit pour l'antispam
push
(
@rndtab
,
$numerics
[
rand
@numerics
]);
# 2-tirage des caractères optionnels : les ajouter au tableau
my
$size
=
10
;
my
@uppers
=
('
A
'
..
'
N
',
'
P
'
..
'
Z
');
my
@lowers
=
('
a
'
..
'
k
',
'
m
'
..
'
z
');
my
@punctuations
=
('
:
',
'
!
',
'
?
',
'
&
',
'
$
',
'
=
',
'
-
',
'
#
');
my
@numerics
=
('
0
'
..
'
9
');
my
@all
=
(
@uppers
,
@lowers
,
@punctuations
,
@numerics
);
# start with a random character of each class
my
@chars
=
(
'
a
'
..
'
k
',
'
m
'
..
'
z
',
'
A
'
..
'
N
',
'
P
'
..
'
Z
',
'
0
'
..
'
9
',
'
_
',
'
%
',
'
;
',
'
:
',
'
!
',
'
?
',
'
&
',
'
$
',
'
*
',
'
(
',
'
)
',
'
{, }
',
'
[
',
'
]
',
'
.
',
'
=
',
'
-
',
'
#
'
$uppers
[
rand
@uppers
],
$lowers
[
rand
@lowers
],
$punctuations
[
rand
@punctuations
],
$numerics
[
rand
@numerics
]
);
foreach
(
5
..
$length_of_randomstring
)
{
# rand @chars will generate a random
# number between 0 and scalar @chars
push
(
@
rndtab
,
$chars
[
rand
@
chars
]);
# complete with additional characters
for
my
$i
(
1
..
$size
-
4
)
{
push
(
@
chars
,
$all
[
rand
@
all
]);
}
# 3-ordonnancement de ceux-ci : les retirer aléatoirement du tableau en les concaténant dans une chaîne
my
$rndstring
=
'';
my
$cpt
=
1
;
while
(
$cpt
<=
$length_of_randomstring
)
{
my
$indice
=
rand
@rndtab
;
$rndstring
.=
$rndtab
[
$indice
];
splice
(
@rndtab
,
$indice
,
1
);
$cpt
+=
1
;
}
return
$rndstring
;
return
join
('',
shuffle
(
@chars
));
}
# ID is based on time + PID
...
...
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