2

I am using FMDB for handling a sqlite db in my application built using rubymotion.

I want to encryt the database with SQLCipher and I am facing issues when I try using SQLCipher methods such as sqlite3_key ?

Has anyone tried out the same ?

**********adding :

When I try to encrypt the database using the sqlite3_key method offered by SQLCipher api , it throws and exception telling the method is not defined.


AaShish Upadhyay
  • 243
  • 3
  • 12

1 Answers1

1

I think you can do this by adding SQLCipher pod then using the FMDB FMDatabase.setKey method and without having to do write any C.

In the Rakefile

app.pods do
  pod 'FMDB'
  pod 'SQLCipher'
end

Then in your Database.rb

class Database
  def self.connection
    unless @connection
      @connection = FMDatabase.databaseWithPath(db_path)
      @connection.traceExecution = true if $debug
      @connection.open
      @connection.setKey 'MySecretKey'
    end
  end
end

Now you should be able to query the db with

Database.connection.executeSelect 'SELECT * from some_table'
alexrothenberg
  • 184
  • 1
  • 9