Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Yeray Santana Hualde
syncEnrollments
Commits
0438c696
Commit
0438c696
authored
Feb 13, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added better random sources in crypter, seed random number generator on every call.
parent
74887986
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
crypter.php
laravel/crypter.php
+30
-1
No files found.
laravel/crypter.php
View file @
0438c696
...
...
@@ -26,7 +26,7 @@ class Crypter {
*/
public
static
function
encrypt
(
$value
)
{
$iv
=
mcrypt_create_iv
(
static
::
iv_size
(),
MCRYPT_RAND
);
$iv
=
mcrypt_create_iv
(
static
::
iv_size
(),
static
::
randomizer
()
);
$value
=
mcrypt_encrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
);
...
...
@@ -58,6 +58,35 @@ class Crypter {
return
rtrim
(
mcrypt_decrypt
(
static
::
$cipher
,
$key
,
$value
,
static
::
$mode
,
$iv
),
"
\0
"
);
}
/**
* Get the most secure random number generator for the system.
*
* @return int
*/
protected
static
function
randomizer
()
{
// There are various sources from which we can get random numbers
// but some are more random than others. We'll choose the most
// random source we can for this server environment.
if
(
defined
(
'MCRYPT_DEV_URANDOM'
))
{
return
MCRYPT_DEV_URANDOM
;
}
elseif
(
defined
(
'MCRYPT_DEV_RANDOM'
))
{
return
MCRYPT_DEV_RANDOM
;
}
// When using the default random number generator, we'll seed
// the generator on each call to ensure the results are as
// random as we can possibly get them.
else
{
mt_srand
();
return
MCRYPT_RAND
;
}
}
/**
* Get the input vector size for the cipher and mode.
*
...
...
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