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
825ac35a
Commit
825ac35a
authored
Jun 17, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve crypt class comments.
parent
fb66bf53
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
crypt.php
system/crypt.php
+12
-7
No files found.
system/crypt.php
View file @
825ac35a
...
...
@@ -25,7 +25,8 @@ class Crypt {
public
static
function
encrypt
(
$value
)
{
// -----------------------------------------------------
// Determine the input vector source.
// Determine the input vector source. Different servers
// and operating systems will have varying options.
// -----------------------------------------------------
if
(
defined
(
'MCRYPT_DEV_URANDOM'
))
{
...
...
@@ -41,21 +42,19 @@ class Crypt {
}
// -----------------------------------------------------
// The system random number generator must be seeded.
// The system random number generator must be seeded
// to produce adequately random results.
// -----------------------------------------------------
if
(
$random
===
MCRYPT_RAND
)
{
mt_srand
();
}
// -----------------------------------------------------
// Create the Mcrypt input vector and encrypt the value.
// -----------------------------------------------------
$iv
=
mcrypt_create_iv
(
static
::
iv_size
(),
$random
);
$value
=
mcrypt_encrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
);
// -----------------------------------------------------
//
Use base64 encoding to get a
string value.
//
We use base64 encoding to get a nice
string value.
// -----------------------------------------------------
return
base64_encode
(
$iv
.
$value
);
}
...
...
@@ -68,6 +67,10 @@ class Crypt {
*/
public
static
function
decrypt
(
$value
)
{
// -----------------------------------------------------
// Since all of our encrypted values are base64 encoded,
// we will decode the value here and verify it.
// -----------------------------------------------------
$value
=
base64_decode
(
$value
,
true
);
if
(
!
$value
)
...
...
@@ -81,7 +84,7 @@ class Crypt {
$iv
=
substr
(
$value
,
0
,
static
::
iv_size
());
// -----------------------------------------------------
// Remove the input vector from the value.
// Remove the input vector from the
encrypted
value.
// -----------------------------------------------------
$value
=
substr
(
$value
,
static
::
iv_size
());
...
...
@@ -106,6 +109,8 @@ class Crypt {
/**
* Get the input vector size for the cipher and mode.
*
* Different ciphers and modes use varying lengths of input vectors.
*
* @return int
*/
private
static
function
iv_size
()
...
...
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