\Defuse\CryptoKey

Summary

Methods
Properties
Constants
createNewRandomKey()
loadFromAsciiSafeString()
saveToAsciiSafeString()
getRawBytes()
No public properties found
KEY_CURRENT_VERSION
KEY_BYTE_SIZE
No protected methods found
No protected properties found
N/A
__construct()
$key_bytes
N/A

Constants

KEY_CURRENT_VERSION

KEY_CURRENT_VERSION

KEY_BYTE_SIZE

KEY_BYTE_SIZE

Properties

$key_bytes

$key_bytes : string

Type

string

Methods

createNewRandomKey()

createNewRandomKey() : \Defuse\Crypto\Key

Creates new random key.

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException

Returns

\Defuse\Crypto\Key

loadFromAsciiSafeString()

loadFromAsciiSafeString(string  $saved_key_string, boolean  $do_not_trim = false) : \Defuse\Crypto\Key

Loads a Key from its encoded form.

By default, this function will call Encoding::trimTrailingWhitespace() to remove trailing CR, LF, NUL, TAB, and SPACE characters, which are commonly appended to files when working with text editors.

Parameters

string $saved_key_string
boolean $do_not_trim

(default: false)

Throws

\Defuse\Crypto\Exception\BadFormatException
\Defuse\Crypto\Exception\EnvironmentIsBrokenException

Returns

\Defuse\Crypto\Key

saveToAsciiSafeString()

saveToAsciiSafeString() : string

Encodes the Key into a string of printable ASCII characters.

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException

Returns

string

getRawBytes()

getRawBytes() : string

Gets the raw bytes of the key.

Returns

string

__construct()

__construct(string  $bytes) 

Constructs a new Key object from a string of raw bytes.

Parameters

string $bytes

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException