Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104145652
PhutilOpaqueEnvelopeKey.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Mar 6, 18:13
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Mar 8, 18:13 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24696509
Attached To
rPHU libphutil
PhutilOpaqueEnvelopeKey.php
View Options
<?php
/**
* Holds the key for @{class:PhutilOpaqueEnvelope} in a logically distant
* location so it will never appear in stack traces, etc. You should never need
* to use this class directly. See @{class:PhutilOpaqueEnvelope} for
* information about opaque envelopes.
*
* @task internal Internals
*/
final
class
PhutilOpaqueEnvelopeKey
{
private
static
$key
;
/* -( Internals )---------------------------------------------------------- */
/**
* @task internal
*/
private
function
__construct
()
{
// <private>
}
/**
* @task internal
*/
public
static
function
getKey
()
{
if
(
self
::
$key
===
null
)
{
// NOTE: We're using a weak random source because cryptographic levels
// of security aren't terribly important here and it allows us to use
// envelopes on systems which don't have a strong random source. Notably,
// this lets us make it to the readbility check for `/dev/urandom` in
// Phabricator on systems where we can't read it.
self
::
$key
=
''
;
for
(
$ii
=
0
;
$ii
<
8
;
$ii
++)
{
self
::
$key
.=
md5
(
mt_rand
(),
$raw_output
=
true
);
}
}
return
self
::
$key
;
}
}
Event Timeline
Log In to Comment