need help with sql chiper

Ram

Member
Licensed User
Longtime User
I'm trying to implemented the sql chiper lib with an encrypted version of my db however I'm hitting a brick wall, the error i get is:

B4X:
info.guardianproject.database.sqlcipher.SQLiteException: file is encrypted or is not a database: , while compiling: SELECT * FROM Version

this is the way (currently) i try to read the encrypted db:

B4X:
Sub Activity_Create(FirstTime As Boolean)

      'clear old DB
      If File.Exists(File.DirInternal ,"test.db") = True Then File.Delete(File.DirInternal,"test.db")
      If File.Exists(File.DirInternal ,"test_encrypted.db") = True Then File.Delete(File.DirInternal,"test_encrypted.db")
      
      'copy db's to the internal dir 
      File.Copy(File.DirAssets,"test.db",File.DirInternal,"test.db")
      File.Copy(File.DirAssets,"test_encrypted.db",File.DirInternal,"test_encrypted.db")
   
      'add the content of sqlcipher_native.zip to DirAssets
      File.Copy(File.DirAssets,"icudt46l.dat",File.DirInternal,"icudt46l.dat")
      File.Copy(File.DirAssets,"libdatabase_sqlcipher.so",File.DirInternal,"libdatabase_sqlcipher.so")
      File.Copy(File.DirAssets,"libsqlcipher_android.so",File.DirInternal,"libsqlcipher_android.so")
      File.Copy(File.DirAssets,"libstlport_shared.so",File.DirInternal,"libstlport_shared.so")
      
      'testing the un encrypted db
      SQL1.Initialize(File.DirInternal, "test.db", True )
      Cursor1 = SQL1.ExecQuery("SELECT * FROM Version")
      Cursor1.Position = 0
      Msgbox(Cursor1.GetString("Release") & Chr(10) & "Release Date: " & Cursor1.GetString("Date"),"un encrypted db")
      Cursor1.Close
      SQL1.Close 
      
      'testing the encrypted db
      SQLChip.Initialize(File.DirInternal, "test_encrypted.db", False, "test",File.DirInternal)
      Cursor1 = SQLChip.ExecQuery("SELECT * FROM Version")
      Cursor1.Position = 0
      Msgbox(Cursor1.GetString("Release") & Chr(10) & "Release Date: " & Cursor1.GetString("Date"),"encrypted db")
      Cursor1.Close
      SQLChip.Close 

End Sub

the problem is I dont know if i'm missing anything in the way i code it or the encrypted db is damaged, i've attached both db (encrypted and un encrypted) to this post inside the zip file.

Thank you all and happy passover.
Best,
Ram
 

Attachments

  • Files.zip
    47.2 KB · Views: 286
Last edited:

Ram

Member
Licensed User
Longtime User
i tried that also without sucess (i didnt know if i should unzip it on the first installation or the lib does it, after trying to add it as zip file and it didnt work i tried to add the content of that zip..)

i created the encrypted db using SQLCipher C/C++ DLL for Windows and one of my team mates wrote me a small app that use that dll (you can download it from the the following link in the next coming hour - http://glassesoff.s3.amazonaws.com/sqlcipher_native.zip?AWSAccessKeyId=AKIAJUAYDKXEI4D3DSJA&Expires=1334840086&Signature=fzYDe7T45l%2fJyT7i%2b4k5OxVJIvY%3d)
 
Upvote 0

susu

Well-Known Member
Licensed User
Longtime User
i created the encrypted db using SQLCipher C/C++ DLL for Windows and one of my team mates wrote me a small app that use that dll

It will be great if you can share your Windows program to encrypt database :sign0060: Thank you in advance :)
 
Upvote 0

Ram

Member
Licensed User
Longtime User
i added a link to it in my post (the link will be expired in the next hour so download it now)
 
Upvote 0
Top