1- # ObjectStorage 2 .0 library
1+ # ObjectStorage 3 .0 library
22
33ObjectStorage library for your cloud-based applications.
44
5- * NOTE: version 1.0, previously only available as dev-master, is still available by updating your composer.json to require version ~ 1.0*
6-
75## Object Storage vs a normal file system
86
97Object-based storage solves large scale storage problems for cloud-based applications.
@@ -78,42 +76,38 @@ $service->delete('my-message');
7876
7977### Encryption
8078
81- The library includes an EncryptionAdapter that will allow you to transparently encrypt/decrypt
79+ The library includes adapters to allow you to transparently encrypt/decrypt
8280your data before it's passed to the storage backend.
8381
84- This is done by wrapping the original storage adapter (s3, file, pdo, gridfs, etc) into
85- the EncryptionAdapter . Here's an example
82+ This is done by wrapping the original storage adapter (s3, file, pdo, gridfs,
83+ etc) into the one of the encryption adapters . Here's an example
8684
8785``` php
88- $adapter = new ObjectStorage\Adapter\PdoAdapter($pdo);
89- $adapter = new ObjectStorage\Adapter\EncryptionAdapter($adapter, $key, $iv);
90- // You can use $adapter as before, but all data will be encrypted
86+ $adapter = new \ObjectStorage\Adapter\EncryptedStorageAdapter(
87+ new \ObjectStorage\Adapter\PdoAdapter($pdo),
88+ \ParagonIE\Halite\KeyFactory::loadEncryptionKey($pathToKeyfile)
89+ );
90+ // You can use $adapter as before and both the storage keys and objects will be
91+ // encrypted (use PlaintextKeyEncryptedStorageAdapter if you don't want the
92+ // storage keys to be encrypted).
9193```
9294
93- The key and iv are hex encoded strings. To generate these, use the following command:
94-
95- ./bin/objectstorage objectstorage: generatekey
95+ The encryption routines are provided by [ ParagonIE/Halite] [ ] and libsodium.
9696
97- This will output something like the following:
98-
99- KEY: C2FE680A5613469189621C9E46B52C15C9C80E50370E7950D6FD2D027C4FAEF0
100- IV: E5F3E442F3CE0ECC931B7E866A5F3121
101-
102- Save these 2 values somewhere safely.
97+ Use the following command to generate an encryption key and save it to a file :-
10398
104- The encryption is similar to using the following commands:
105-
106- openssl enc -aes-256-cbc -K C2FE680A5613469189621C9E46B52C15C9C80E50370E7950D6FD2D027C4FAEF0 -iv E5F3E442F3CE0ECC931B7E866A5F3121 < original.txt > encrypted.aes
99+ ``` sh
100+ ./bin/objectstorage genkey /path/to/a/file
101+ ```
107102
108- openssl enc -d -aes-256-cbc -K C2FE680A5613469189621C9E46B52C15C9C80E50370E7950D6FD2D027C4FAEF0 -iv E5F3E442F3CE0ECC931B7E866A5F3121 < encrypted.aes
109-
110- You can also use the included encrypt + decrypt commands :
103+ You can also use the included encrypt + decrypt commands. In the following
104+ example we encrypt ` example.pdf ` with the encryption key in ` key.asc ` and then
105+ decrypt it again, using the same key and writing it to a new ` example-new.pdf ` :
111106
112- export OBJECTSTORAGE_ENCRYPTION_KEY=C2FE680A5613469189621C9E46B52C15C9C80E50370E7950D6FD2D027C4FAEF0
113- export OBJECTSTORAGE_ENCRYPTION_IV=E5F3E442F3CE0ECC931B7E866A5F3121
114-
115- bin/objectstorage objectstorage:encrypt example.pdf > example.pdf.encrypted
116- bin/objectstorage objectstorage:decrypt example.pdf.encrypted > example_new.pdf
107+ ``` sh
108+ bin/objectstorage encrypt key.asc example.pdf example.pdf.encrypted
109+ bin/objectstorage decrypt key.asc example.pdf.encrypted example-new.pdf
110+ ```
117111
118112## Console tool
119113
@@ -172,11 +166,20 @@ Then, add `linkorb/objectstorage` to your project's `composer.json`:
172166``` json
173167{
174168 "require" : {
175- "linkorb/objectstorage" : " ~2 .0"
169+ "linkorb/objectstorage" : " ^3 .0"
176170 }
177171}
178172```
179173
174+ ## Older versions of this library
175+
176+ Version 1.0, previously only available as dev-master, is still available by
177+ updating your composer.json to require version "~ 1.0".
178+
179+ The ` php5 ` branch will still work with PHP <= 5.6, but it will not have the
180+ latest features and, particularly, should not be used if you need encrypted
181+ storage.
182+
180183## Contributing
181184
182185Ready to build and improve on this repo? Excellent!
@@ -195,3 +198,5 @@ Btw, we're hiring!
195198## License
196199
197200Please check LICENSE.md for full license information
201+
202+ [ ParagonIE/Halite ] : < https://paragonie.com/project/halite > " Halite - Simple PHP Cryptography Library "
0 commit comments