PHP Class Defuse\Crypto\File

显示文件 Open project: defuse/php-encryption Class Usage Examples

Public Methods

Method Description
decryptFile ( string $inputFilename, string $outputFilename, Defuse\Crypto\Key $key ) Decrypts the input file, saving the plaintext to the output file.
decryptFileWithPassword ( string $inputFilename, string $outputFilename, string $password ) Decrypts a file with a password, using a slow key derivation function to make password cracking more expensive.
decryptResource ( resource $inputHandle, resource $outputHandle, Defuse\Crypto\Key $key ) Takes two resource handles and decrypts the contents of the first, writing the plaintext into the second.
decryptResourceInternal ( resource $inputHandle, resource $outputHandle, KeyOrPassword $secret ) Decrypts a file-backed resource with either a key or a password.
decryptResourceWithPassword ( resource $inputHandle, resource $outputHandle, string $password ) Decrypts the contents of one resource into another with a password, using a slow key derivation function to make password cracking more expensive.
encryptFile ( string $inputFilename, string $outputFilename, Defuse\Crypto\Key $key ) Encrypts the input file, saving the ciphertext to the output file.
encryptFileWithPassword ( string $inputFilename, string $outputFilename, string $password ) Encrypts a file with a password, using a slow key derivation function to make password cracking more expensive.
encryptResource ( resource $inputHandle, resource $outputHandle, Defuse\Crypto\Key $key ) Takes two resource handles and encrypts the contents of the first, writing the ciphertext into the second.
encryptResourceWithPassword ( resource $inputHandle, resource $outputHandle, string $password ) Encrypts the contents of one resource handle into another with a password, using a slow key derivation function to make password cracking more expensive.
readBytes ( resource $stream, integer $num_bytes ) : string Read from a stream; prevent partial reads.
writeBytes ( resource $stream, string $buf, integer $num_bytes = null ) : string Write to a stream; prevents partial writes.

Private Methods

Method Description
decryptFileInternal ( string $inputFilename, string $outputFilename, KeyOrPassword $secret ) Decrypts a file with either a key or a password.
encryptFileInternal ( string $inputFilename, string $outputFilename, KeyOrPassword $secret ) Encrypts a file with either a key or a password.
encryptResourceInternal ( resource $inputHandle, resource $outputHandle, KeyOrPassword $secret ) Encrypts a resource with either a key or a password.
getLastErrorMessage ( ) : string Returns the last PHP error's or warning's message string.

Method Details

decryptFile() public static method

Decrypts the input file, saving the plaintext to the output file.
public static decryptFile ( string $inputFilename, string $outputFilename, Defuse\Crypto\Key $key )
$inputFilename string
$outputFilename string
$key Defuse\Crypto\Key

decryptFileWithPassword() public static method

Decrypts a file with a password, using a slow key derivation function to make password cracking more expensive.
public static decryptFileWithPassword ( string $inputFilename, string $outputFilename, string $password )
$inputFilename string
$outputFilename string
$password string

decryptResource() public static method

Takes two resource handles and decrypts the contents of the first, writing the plaintext into the second.
public static decryptResource ( resource $inputHandle, resource $outputHandle, Defuse\Crypto\Key $key )
$inputHandle resource
$outputHandle resource
$key Defuse\Crypto\Key

decryptResourceInternal() public static method

Decrypts a file-backed resource with either a key or a password.
public static decryptResourceInternal ( resource $inputHandle, resource $outputHandle, KeyOrPassword $secret )
$inputHandle resource
$outputHandle resource
$secret KeyOrPassword

decryptResourceWithPassword() public static method

Decrypts the contents of one resource into another with a password, using a slow key derivation function to make password cracking more expensive.
public static decryptResourceWithPassword ( resource $inputHandle, resource $outputHandle, string $password )
$inputHandle resource
$outputHandle resource
$password string

encryptFile() public static method

Encrypts the input file, saving the ciphertext to the output file.
public static encryptFile ( string $inputFilename, string $outputFilename, Defuse\Crypto\Key $key )
$inputFilename string
$outputFilename string
$key Defuse\Crypto\Key

encryptFileWithPassword() public static method

Encrypts a file with a password, using a slow key derivation function to make password cracking more expensive.
public static encryptFileWithPassword ( string $inputFilename, string $outputFilename, string $password )
$inputFilename string
$outputFilename string
$password string

encryptResource() public static method

Takes two resource handles and encrypts the contents of the first, writing the ciphertext into the second.
public static encryptResource ( resource $inputHandle, resource $outputHandle, Defuse\Crypto\Key $key )
$inputHandle resource
$outputHandle resource
$key Defuse\Crypto\Key

encryptResourceWithPassword() public static method

Encrypts the contents of one resource handle into another with a password, using a slow key derivation function to make password cracking more expensive.
public static encryptResourceWithPassword ( resource $inputHandle, resource $outputHandle, string $password )
$inputHandle resource
$outputHandle resource
$password string

readBytes() public static method

Read from a stream; prevent partial reads.
public static readBytes ( resource $stream, integer $num_bytes ) : string
$stream resource
$num_bytes integer
return string

writeBytes() public static method

Write to a stream; prevents partial writes.
public static writeBytes ( resource $stream, string $buf, integer $num_bytes = null ) : string
$stream resource
$buf string
$num_bytes integer
return string