Download the PHP package jsq/psr7-stream-encryption without Composer
On this page you can find all versions of the php package jsq/psr7-stream-encryption. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jsq/psr7-stream-encryption
More information about jsq/psr7-stream-encryption
Files in jsq/psr7-stream-encryption
Package psr7-stream-encryption
Short Description For encrypting and decrypting streams of arbitrary size.
License Apache-2.0
Informations about the package psr7-stream-encryption
PSR-7 Stream Encryption Decorators
PHP's built-in OpenSSL bindings provide a convenient means of encrypting and
decrypting data. The interface provided by ext-openssl
, however, only operates
on strings, so decrypting a large ciphertext would require loading the entire
ciphertext into memory and receiving a string containing the entirety of the
decoded plaintext.
This package aims to allow the encryption and decryption of streams of arbitrary size. It supports streaming encryption and decryption using AES-CBC, AES-CTR, and AES-ECB.
Using AES-ECB is NOT RECOMMENDED for new systems. It is included to allow interoperability with older systems. Please consult Wikipedia for a discussion of the drawbacks of ECB.
Usage
Decorate an instance of Psr\Http\Message\StreamInterface
with an encrypting
decorator to incrementally encrypt the contents of the decorated stream as
read
is called on the decorating stream:
No encryption is performed until read
is called on the encrypting stream.
To calculate the HMAC of a cipher text, wrap a decorated stream with an instance
of HashingStream
:
When decrypting a cipher text, wrap the cipher text in a hasing decorator before passing it as an argument to the decrypting stream:
As with the encrypting decorators, HashingStream
s are lazy and will only hash
the underlying stream as it is read. In the example above, no exception would be
thrown until the entire cipher text had been read (and all but the last block
deciphered).
HashingStream
s are not seekable, so you will need to wrap on in a
GuzzleHttp\Psr7\CachingStream
to support random access.
All versions of psr7-stream-encryption with dependencies
ext-openssl Version *
guzzlehttp/psr7 Version ~1.0
psr/http-message Version ~1.0