Methods

encryptFile()

encryptFile(string  $inputFilename, string  $outputFilename, \Defuse\Crypto\Key  $key) : void

Encrypts the input file, saving the ciphertext to the output file.

Parameters

string $inputFilename
string $outputFilename
\Defuse\Crypto\Key $key

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException

encryptFileWithPassword()

encryptFileWithPassword(string  $inputFilename, string  $outputFilename, string  $password) : void

Encrypts a file with a password, using a slow key derivation function to make password cracking more expensive.

Parameters

string $inputFilename
string $outputFilename
string $password

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException

decryptFile()

decryptFile(string  $inputFilename, string  $outputFilename, \Defuse\Crypto\Key  $key) : void

Decrypts the input file, saving the plaintext to the output file.

Parameters

string $inputFilename
string $outputFilename
\Defuse\Crypto\Key $key

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException
\Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException

decryptFileWithPassword()

decryptFileWithPassword(string  $inputFilename, string  $outputFilename, string  $password) : void

Decrypts a file with a password, using a slow key derivation function to make password cracking more expensive.

Parameters

string $inputFilename
string $outputFilename
string $password

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException
\Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException

encryptResource()

encryptResource(resource  $inputHandle, resource  $outputHandle, \Defuse\Crypto\Key  $key) : void

Takes two resource handles and encrypts the contents of the first, writing the ciphertext into the second.

Parameters

resource $inputHandle
resource $outputHandle
\Defuse\Crypto\Key $key

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException

encryptResourceWithPassword()

encryptResourceWithPassword(resource  $inputHandle, resource  $outputHandle, string  $password) : void

Encrypts the contents of one resource handle into another with a password, using a slow key derivation function to make password cracking more expensive.

Parameters

resource $inputHandle
resource $outputHandle
string $password

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException
\Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException

decryptResource()

decryptResource(resource  $inputHandle, resource  $outputHandle, \Defuse\Crypto\Key  $key) : void

Takes two resource handles and decrypts the contents of the first, writing the plaintext into the second.

Parameters

resource $inputHandle
resource $outputHandle
\Defuse\Crypto\Key $key

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException
\Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException

decryptResourceWithPassword()

decryptResourceWithPassword(resource  $inputHandle, resource  $outputHandle, string  $password) : void

Decrypts the contents of one resource into another with a password, using a slow key derivation function to make password cracking more expensive.

Parameters

resource $inputHandle
resource $outputHandle
string $password

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException
\Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException

decryptResourceInternal()

decryptResourceInternal(resource  $inputHandle, resource  $outputHandle, \Defuse\Crypto\KeyOrPassword  $secret) : void

Decrypts a file-backed resource with either a key or a password.

Parameters

resource $inputHandle
resource $outputHandle
\Defuse\Crypto\KeyOrPassword $secret

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException
\Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException

readBytes()

readBytes(resource  $stream, integer  $num_bytes) : string

Read from a stream; prevent partial reads.

Parameters

resource $stream
integer $num_bytes

Throws

\Defuse\Crypto\Exception\IOException
\Defuse\Crypto\Exception\EnvironmentIsBrokenException

Returns

string

writeBytes()

writeBytes(resource  $stream, string  $buf, integer  $num_bytes = null) : integer

Write to a stream; prevents partial writes.

Parameters

resource $stream
string $buf
integer $num_bytes

Throws

\Defuse\Crypto\Exception\IOException

Returns

integer

encryptFileInternal()

encryptFileInternal(string  $inputFilename, string  $outputFilename, \Defuse\Crypto\KeyOrPassword  $secret) : void

Encrypts a file with either a key or a password.

Parameters

string $inputFilename
string $outputFilename
\Defuse\Crypto\KeyOrPassword $secret

Throws

\Defuse\Crypto\Exception\CryptoException
\Defuse\Crypto\Exception\IOException

decryptFileInternal()

decryptFileInternal(string  $inputFilename, string  $outputFilename, \Defuse\Crypto\KeyOrPassword  $secret) : void

Decrypts a file with either a key or a password.

Parameters

string $inputFilename
string $outputFilename
\Defuse\Crypto\KeyOrPassword $secret

Throws

\Defuse\Crypto\Exception\CryptoException
\Defuse\Crypto\Exception\IOException

encryptResourceInternal()

encryptResourceInternal(resource  $inputHandle, resource  $outputHandle, \Defuse\Crypto\KeyOrPassword  $secret) : void

Encrypts a resource with either a key or a password.

Parameters

resource $inputHandle
resource $outputHandle
\Defuse\Crypto\KeyOrPassword $secret

Throws

\Defuse\Crypto\Exception\EnvironmentIsBrokenException
\Defuse\Crypto\Exception\IOException

getLastErrorMessage()

getLastErrorMessage() : string

Returns the last PHP error's or warning's message string.

Returns

string