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
77d65b89
Commit
77d65b89
authored
Jul 08, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring crypt class.
parent
6e93237e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
crypt.php
system/crypt.php
+24
-17
No files found.
system/crypt.php
View file @
77d65b89
...
@@ -24,21 +24,8 @@ class Crypt {
...
@@ -24,21 +24,8 @@ class Crypt {
*/
*/
public
static
function
encrypt
(
$value
)
public
static
function
encrypt
(
$value
)
{
{
if
(
defined
(
'MCRYPT_DEV_URANDOM'
))
// Seed the system random number generator if it is being used.
{
if
((
$random
=
static
::
randomizer
())
===
MCRYPT_RAND
)
$random
=
MCRYPT_DEV_URANDOM
;
}
elseif
(
defined
(
'MCRYPT_DEV_RANDOM'
))
{
$random
=
MCRYPT_DEV_RANDOM
;
}
else
{
$random
=
MCRYPT_RAND
;
}
// The system random number generator must be seeded to produce random results.
if
(
$random
===
MCRYPT_RAND
)
{
{
mt_srand
();
mt_srand
();
}
}
...
@@ -47,7 +34,6 @@ class Crypt {
...
@@ -47,7 +34,6 @@ class Crypt {
$value
=
mcrypt_encrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
);
$value
=
mcrypt_encrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
);
// Use base64 encoding to get a nice string value.
return
base64_encode
(
$iv
.
$value
);
return
base64_encode
(
$iv
.
$value
);
}
}
...
@@ -76,7 +62,28 @@ class Crypt {
...
@@ -76,7 +62,28 @@ class Crypt {
}
}
/**
/**
* Get the application key.
* Get the random number source that should be used for the OS.
*
* @return int
*/
private
static
function
randomizer
()
{
if
(
defined
(
'MCRYPT_DEV_URANDOM'
))
{
return
MCRYPT_DEV_URANDOM
;
}
elseif
(
defined
(
'MCRYPT_DEV_RANDOM'
))
{
return
MCRYPT_DEV_RANDOM
;
}
else
{
return
MCRYPT_RAND
;
}
}
/**
* Get the application key from the application configuration file.
*
*
* @return string
* @return string
*/
*/
...
...
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