Re: [sqlite] SQLite Encryption Extension For Use with With PHP 7.x Code

2019-08-20 Thread Simon Slavin
On 20 Aug 2019, at 8:40pm, Mark Tomlin  wrote:

> I found the regular sqlite3::open method has an $encryption_key parameter.
> 
> https://www.php.net/manual/en/sqlite3.open.php

Yep.

> As I am using PDO for the interface into SQLite, I wonder if there is a 
> similar parameter for that interface.

Nope.  The @passwd parameter is for user authentication, not encryption.

If there's way to do it with the PDO module, I'm betting that it's using PRAGMA:

PRAGMA key='your-secret-key';

Issue this as a SQL command immediately after you've opened the SQLite database 
using PDO.  It might work in PHP.  I've never tried it.  If it doesn't work 
there's probably no way to make it work short of compiling your own copy of PHP.

You might use the sqlite3 module to create a tiny test encrypted database, with 
a row of data, for you to do testing on.  If you can successfully read that 
database using PDO try using the above PRAGMA with a freshly-created database 
to see if PDO can be used to encrypt.

Refs:


___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLite Encryption Extension For Use with With PHP 7.x Code

2019-08-20 Thread Richard Hipp
On 8/20/19, Mark Tomlin  wrote:
> I've looked at the PRAGMA statements and there doesn't appear to
> be any public documentation on this interface.

The PRAGMAs in question are part of the SEE documentation, as they are
unique to SEE.

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLite Encryption Extension For Use with With PHP 7.x Code

2019-08-20 Thread Mark Tomlin
Thank you Richard for the extremely quick response.

I found the regular sqlite3::open method has an $encryption_key parameter.

https://www.php.net/manual/en/sqlite3.open.php

As I am using PDO for the interface into SQLite, I wonder if there is a
similar parameter for that interface. Perhaps using the $password
parameter? There is very little documentation on this.

https://www.php.net/manual/en/pdo.construct.php

I see that you mentioned using PRAGMA statement for the activation of
encryption. From my currently unencrypted database, and connecting to the
SQLite database with PDO, how would I enable the encryption and then for
subsequent queries ensure that the database file remains readable by my
code base? I've looked at the PRAGMA statements and there doesn't appear to
be any public documentation on this interface.

https://www.sqlite.org/pragma.html

I do understand this is outside of the scope of SQLite when asking for help
with PHP's PDO interface. I'm just hoping that people on here have
experience with PHP might have a solution.



On Tue, Aug 20, 2019 at 2:56 PM Richard Hipp  wrote:

> On 8/20/19, Mark Tomlin  wrote:
> > I would like to use SQLite's Encryption Extension with my PHP 7.2 code
> > base, as well as 7.3 and 7.4 code bases moving forward. My hope is is
> that
> > the see-sqlite.c code file can be simply renaming it to sqlite.c and
> > dropping it into PHP's build directory.Then compiling it as I normally
> > would. I'm also guessing I would have to modify the (see-)sqlite.c code
> to
> > make a call to sqlite3_key from within the sqlite3 function call so
> > that the encryption is always on and would not require any modifications
> to
> > the PHP source code.
>
> You do not need to modify any C code, either in SQLite/SEE or in PHP.
> You can activate encryption and set the encryption key using a PRAGMA
> statement.
>
> >
> > Has anyone done this before?
>
> Yes.
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Mark Tomlin, CEO.
MimoCAD, Inc.
P: (516) 234-0290
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLite Encryption Extension For Use with With PHP 7.x Code

2019-08-20 Thread Richard Hipp
On 8/20/19, Mark Tomlin  wrote:
> I would like to use SQLite's Encryption Extension with my PHP 7.2 code
> base, as well as 7.3 and 7.4 code bases moving forward. My hope is is that
> the see-sqlite.c code file can be simply renaming it to sqlite.c and
> dropping it into PHP's build directory.Then compiling it as I normally
> would. I'm also guessing I would have to modify the (see-)sqlite.c code to
> make a call to sqlite3_key from within the sqlite3 function call so
> that the encryption is always on and would not require any modifications to
> the PHP source code.

You do not need to modify any C code, either in SQLite/SEE or in PHP.
You can activate encryption and set the encryption key using a PRAGMA
statement.

>
> Has anyone done this before?

Yes.


-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQLite Encryption Extension For Use with With PHP 7.x Code

2019-08-20 Thread Mark Tomlin
I would like to use SQLite's Encryption Extension with my PHP 7.2 code
base, as well as 7.3 and 7.4 code bases moving forward. My hope is is that
the see-sqlite.c code file can be simply renaming it to sqlite.c and
dropping it into PHP's build directory.Then compiling it as I normally
would. I'm also guessing I would have to modify the (see-)sqlite.c code to
make a call to sqlite3_key from within the sqlite3 function call so
that the encryption is always on and would not require any modifications to
the PHP source code.

Has anyone done this before?

-- 
Mark Tomlin, CEO.
MimoCAD, Inc.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users