store encrypted data in sqlite ?

Discussion in 'Python' started by Stef Mientki, Oct 2, 2009.

  1. Stef Mientki

    Stef Mientki Guest

    hello,

    I want to store some fields in an sqlite database.

    I use ezPyCrypto to encrypt and decrypt:

    User = ['z684684', 'Mientki, Stef', 1,1,0,1,1 ]

    encryption_key_1 = ezPyCrypto.key ( 512 )

    SQL_Base = 'insert or replace into __USERS__ values ('
    for field in User :
    SQL += ",'" + encryption_key_1.encString ( str ( item ))+ "'"
    SQL += ')'


    Now this fails, probably, because the second character of the encrypted
    string is a binary zero.

    By trial and error, I found a work around,
    but I'm not sure this will garantee that it will work always:
    by converting the encrypted buffer with base64.encode:

    SQL += ",'" + base64.encodestring(EnCrypt_1 ( str ( item )))+ "'"

    Will this method work always ?
    Are there better methods ?

    thanks,
    Stef Mientki
     
    Stef Mientki, Oct 2, 2009
    #1
    1. Advertising

  2. On Oct 2, 11:53 am, Stef Mientki <> wrote:
    >
    > Will this method work always ?
    > Are there better methods ?
    >


    I SQLite doesn't like raw data (with all its \0 glory), you're out of
    luck, unfortunately. Base64 encoding is a really good solution for
    places like this.

    You are aware, of course, of the dangers of storing sensitive data in
    memory? That is, if you are storing the sensitive data anywhere in a
    Python variable, it is possible for someone with access to the memory
    of the machine to discover it.

    If it is only the storage of the sensitive data you are concerned
    about, or the sensitivity of the data if it is transferred over the
    network, there are other, easier ways to protect the data than in an
    encrypted field.
     
    Jonathan Gardner, Oct 2, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UnVkeQ==?=

    to store or not to store an image

    =?Utf-8?B?UnVkeQ==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    677
    =?Utf-8?B?UnVkeQ==?=
    Mar 30, 2005
  2. root@127.0.0.1
    Replies:
    1
    Views:
    6,080
    Roedy Green
    Oct 15, 2005
  3. Replies:
    4
    Views:
    10,826
    Harri Tuuloskoski
    Mar 22, 2006
  4. Carl Youngblood
    Replies:
    1
    Views:
    264
    Carl Youngblood
    Apr 9, 2005
  5. Replies:
    4
    Views:
    375
Loading...

Share This Page