SDK for PHP 3.x

Key
in package

Class Key

Wraps a string to keep it hidden from stack traces.

Table of Contents

Methods

__construct()  : mixed
Key constructor.
__debugInfo()  : array<string|int, mixed>
Hide contents of
__destruct()  : mixed
Defense in depth:
get()  : string
length()  : int

Methods

__construct()

Key constructor.

public __construct(string $str) : mixed
Parameters
$str : string

__debugInfo()

Hide contents of

public __debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>

__destruct()

Defense in depth:

public __destruct() : mixed

PHP 7.2 includes the Sodium cryptography library, which (among other things) exposes a function called sodium_memzero() that we can use to zero-fill strings to minimize the risk of sensitive cryptographic materials persisting in memory.

If this function is not available, we XOR the string in-place with itself as a best-effort attempt.

get()

public get() : string
Return values
string

length()

public length() : int
Return values
int
On this page