instant php happiness: PDO_sqlcipher

95 views
Skip to first unread message

Vincent Kersten

unread,
May 23, 2013, 9:48:02 AM5/23/13
to sqlc...@googlegroups.com, Anton Batenev
Dear members,
happy to tell you that i came into contact with a php PDO driver for sqlcipher at
this circumvents all tedious patching of the  php sqlite3 module and 'simply' adds a php PDO extension for sqlcipher : pdo_sqlcipher.so.
It makes for a much cleaner setup, if you have pdo enable on your server. 
On my request Anton added an example.php script to his github page so you can also immediately see how it works. 

The page is a little Debian oriented (which is great ! however i use redhat on the server i am creating this app), so here are the general instructions if you want to use his project on redhat-ish machines:

 =-=-=-=-

Install dependencies:

sudo yum install libicu-devel readline-devel openssl-devel php-devel php-pdo tcl-devel git 

git clone https://github.com/abbat/pdo_sqlcipher.git

cd pdo_sqlcipher

./build.sh

sudo echo "extension=pdo_sqlcipher.so" > /etc/php.d/pdo_sqlcipher.ini

sudo cp release/pdo_sqlcipher.so /usr/lib64/php/modules/

sudo cp release/sqlcipher /usr/local/bin/

# Now Lets test!

php example.php 

# The output of the example.php should corrospond to:
Array
(
   [id] => 1
   [0] => 1
   [value] => value1
   [1] => value1
)
Array
(
   [id] => 2
   [0] => 2
   [value] => value2
   [1] => value2
)
Array
(
   [id] => 3
   [0] => 3
   [value] => value3
   [1] => value3
)

and you should now have a encrypted database file 'example.db' in your directory.

Lets try via sqlcipher database program directly:

sqlcipher example.db
...
sqlite> PRAGMA key = '123456';
sqlite> PRAGMA encoding = "UTF-8";
sqlite> SELECT * FROM `test`;
1|value1
2|value2
3|value3
sqlite> INSERT INTO `test` VALUES (4, 'another one');
sqlite> SELECT * FROM `test`;
1|value1
2|value2
3|value3
4|another one
sqlite> ^D


That's it folks!

=-=-=-=-

I hope the sqlcipher ppl here can endorse this idea/project on their page, I it helped me a lot!

Thanks,


  Vincent




Nick Parker

unread,
May 23, 2013, 3:49:49 PM5/23/13
to sqlc...@googlegroups.com, Anton Batenev
Hi Vincent,

Thanks for sharing, another option for using SQLCipher on PHP!

Nick Parker






--
 
---
You received this message because you are subscribed to the Google Groups "SQLCipher Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlcipher+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages