2

我在使用 ruby​​motion 构建的应用程序中使用 FMDB 处理 sqlite 数据库。

我想用 SQLCipher 加密数据库,当我尝试使用 SQLCipher 方法(如sqlite3_key )时遇到问题?

有没有人尝试过相同的?

** * ** * *** *添加:

当我尝试使用 SQLCipher api 提供的 sqlite3_key 方法加密数据库时,它会抛出异常,并告诉该方法未定义。


4

1 回答 1

1

我认为您可以通过添加SQLCipherpod 然后使用该FMDB FMDatabase.setKey方法来做到这一点,而无需编写任何 C。

在里面Rakefile

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

然后在你的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

现在您应该可以使用

Database.connection.executeSelect 'SELECT * from some_table'
于 2013-01-22T19:17:42.717 回答