-1
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
   }

I am trying to use 1)FMDB Pod 2)SQLCipher pod with a Rubymotion iOS project.

I am trying to encrypt the database with SQLCipher but Rubymotion does not recognize the methods offered by SQLCipher.

I have found the below mentioned piece of code which people have reported to be running in Objective C and xcode.

Can Someone please convert this to Rubymotion ?

AaShish Upadhyay
  • 243
  • 3
  • 12

1 Answers1

0

I don't think you need to convert this to RubyMotion. You can call this FMDB code from RubyMotion with something like

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 

See my answer in Using FMDB + SQLCipher with Rubymotion?

Community
  • 1
  • 1
alexrothenberg
  • 184
  • 1
  • 9