【问题标题】:Convert Objective C to Rubymotion将 Objective C 转换为 Rubymotion
【发布时间】:2013-01-21 15:17:18
【问题描述】:
SQLCIPHER sqlite encrypted iphone ios converting un-encrypted database to encrypted database
[fmdb open];
       NSString *sel = @"SELECT count(*) FROM sqlite_master";            
       FMResultSet *fmr = [self executeQuery : fmdb : sel];

        if ( [fmr next] ) // unencrypted
        {
            NSLog(@"Encrypting");
            fmdb.key = @"";
            [fmdb rekey : @"somekey"];
        }

- (BOOL)rekey:(NSString*)key {
    #ifdef SQLITE_HAS_CODEC
    if (!key) {
        return NO;
    }

    int rc = sqlite3_rekey(db, [key UTF8String], (int)strlen([key UTF8String]));

    if (rc != SQLITE_OK) {
        NSLog(@"error on rekey: %d", rc);
        NSLog(@"%@", [self lastErrorMessage]);
    }

    return (rc == SQLITE_OK);
    #else
        return NO;
    #endif
   }

我正在尝试使用 1)FMDB 吊舱 2)SQLCipher 吊舱 使用 Rubymotion iOS 项目。

我正在尝试使用 SQLCipher 加密数据库,但 Rubymotion 无法识别 SQLCipher 提供的方法。

我发现了下面提到的一段代码,人们报告说它在 Objective C 和 xcode 中运行。

有人可以将其转换为 Rubymotion 吗?

【问题讨论】:

    标签: fmdb rubymotion sqlcipher


    【解决方案1】:

    我认为您不需要将其转换为 RubyMotion。你可以从 RubyMotion 调用这个 FMDB 代码,比如

    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 
    

    Using FMDB + SQLCipher with Rubymotion?查看我的回答

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-10
      • 2012-11-15
      • 2017-10-24
      • 2012-10-06
      • 2011-12-04
      • 1970-01-01
      相关资源
      最近更新 更多