Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92594008
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, Nov 21, 19:48
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Nov 23, 19:48 (2 d)
Engine
blob
Format
Raw Data
Handle
22465976
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
)
{
try
{
self
::
$key
=
Filesystem
::
readRandomBytes
(
128
);
}
catch
(
Exception
$ex
)
{
// NOTE: We can't throw here! Otherwise we might get a stack trace
// including the string that was passed to PhutilOpaqueEnvelope's
// constructor. Just die() instead.
die
(
"Unable to read random bytes in PhutilOpaqueEnvelope. (This "
.
"causes an immediate process exit to avoid leaking the envelope "
.
"contents in a stack trace.)"
);
}
}
return
self
::
$key
;
}
}
Event Timeline
Log In to Comment