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
1916e27d
Commit
1916e27d
authored
Aug 08, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring the crypt class.
parent
bc51ec3d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
9 deletions
+3
-9
crypt.php
system/crypt.php
+3
-9
No files found.
system/crypt.php
View file @
1916e27d
...
...
@@ -24,8 +24,7 @@ class Crypt {
*/
public
static
function
encrypt
(
$value
)
{
// If the system random number generator is being used, we need to seed
// it to get adequately random results.
// Seed the system random number generator so it will produce random results.
if
((
$random
=
static
::
randomizer
())
===
MCRYPT_RAND
)
mt_srand
();
$iv
=
mcrypt_create_iv
(
static
::
iv_size
(),
$random
);
...
...
@@ -50,10 +49,8 @@ class Crypt {
throw
new
\Exception
(
'Decryption error. Input value is not valid base64 data.'
);
}
// Extract the input vector from the value.
$iv
=
substr
(
$value
,
0
,
static
::
iv_size
());
// Remove the input vector from the encrypted value.
$value
=
substr
(
$value
,
static
::
iv_size
());
return
rtrim
(
mcrypt_decrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
),
"
\0
"
);
...
...
@@ -87,12 +84,9 @@ class Crypt {
*/
private
static
function
key
()
{
if
(
is_null
(
$key
=
Config
::
get
(
'application.key'
))
or
$key
==
''
)
{
throw
new
\Exception
(
"The encryption class can not be used without an encryption key."
);
}
if
(
!
is_null
(
$key
=
Config
::
get
(
'application.key'
))
and
$key
!==
''
)
return
$key
;
return
$key
;
throw
new
\Exception
(
"The encryption class can not be used without an encryption key."
)
;
}
/**
...
...
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