Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I default to sqlcipher4 with sequelize? #33

Open
rohit5ram opened this issue Apr 16, 2020 · 3 comments
Open

How can I default to sqlcipher4 with sequelize? #33

rohit5ram opened this issue Apr 16, 2020 · 3 comments

Comments

@rohit5ram
Copy link

const Sequelize = require("sequelize");
const db = new Sequelize({
    dialect: 'sqlite',
    storage: path.join(process.cwd(), "sample.db"),
    dialectModulePath: '@journeyapps/sqlcipher',
    logging: false,
    define: {
        freezeTableName: true
    }
});
db.query("PRAGMA key = 'password'");

I am not able to open the sample.db file with sqlitebrowser SQLCIPHER 4.
Screenshot from 2020-04-16 11-57-50

The only way its works is by adding the below line and then use SQLICIPHER 3 in sqlitebrowser
db.query('PRAGMA cipher_compatibility = 3'); Screenshot from 2020-04-16 11-58-50

@rkistner
Copy link
Member

Which version of this package are you using?

The SQLCipher 4 defaults should be used by default, so I'm not sure why this isn't working.

You can try to set the individual parameters explicitly to match sqlitebrowser:

PRAGMA cipher_page_size = 4096;
PRAGMA kdf_iter = 256000;
PRAGMA cipher_hmac_algorithm = HMAC_SHA512;
PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA512;

@rohit5ram
Copy link
Author

@rkistner I use @journeyapps/sqlcipher": "^4.1.0

@rkistner
Copy link
Member

I've tested with @journeyapps/sqlcipher versions 4.1.0 and 5.0.0, and couldn't reproduce in either version.

Tested with sqlitebrowser 3.12.99 / sqlcipher 4.3.0.

If you still run into the issue, I recommend:

  1. Test with the sqlcipher CLI instead of sqlitebrowser.
  2. Test using this library directly, without sequelize.

Also check whether adding PRAGMA cipher_compatibility = 4 (before setting the key) makes a difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants