Skip to content

Basic structure program to cipher database with AES 128 to read and write #96

Description

@Zapotecatl

Hello,

I did my basic structure program in order to cipher my database with AES 128 to read and write:

#include <stdio.h>
#include <string.h>
#include <sqlite3mc.h>

int main(){
  int rc;
  sqlite3 *db;
  
  rc = sqlite3_open("demo.db", &db);
  
  if(rc != SQLITE_OK){
  
    rc = sqlite3mc_config(db, "default:cipher", sqlite3mc_cipher_index("aes128cbc"));
    if (!(rc < 0)) {
      printf("configure the cipher successful\n");
    }
    else {
      printf("failed to configure the cipher\n");
    }
    
    // Multiple cipher encrypt the database with AES 128
    const char *password = "demo";
    rc = sqlite3_key(db, password, strlen(password));
    if(rc != SQLITE_OK){
       printf("failed to key database\n");
    }
	
    // HERE //////////////////////
    //  My stuff
    //////////////////////////////////////////
  }
  else {
    printf("failed to open database\n");
  }
  
  if(db != NULL){
    sqlite3_close(db);
  }
}

I run my program and seems all works fine.

Thinking in this requirement: "Cipher your SQLite database with AES 128 for read and write".

My question is: this basic structure program accomplish the requirement?

I appreciate a lot your help, thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions