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 to use db.pragma('key, "some-long-string-with-quotes")? #78

Closed
titanism opened this issue Dec 10, 2023 · 2 comments
Closed

How to use db.pragma('key, "some-long-string-with-quotes")? #78

titanism opened this issue Dec 10, 2023 · 2 comments
Labels
needs-debugging 🪲 This issue needs debugging to further narrow it down stale This issue/PR has been inactive for a long time waiting-author-response ⏳ The issue is blocked till the author responds

Comments

@titanism
Copy link
Contributor

titanism commented Dec 10, 2023

We've read at https://www.zetetic.net/sqlcipher/sqlcipher-api/#example-2-raw-key-data-without-key-derivation that PRAGMA key accepts a "64 character hex string".

Screen Shot 2023-12-10 at 11 54 07 AM

How might we write this with pure JavaScript? Is there a way to do db.pragma('key', Buffer.from('something-with-quotes').toString('hex')) and pad it with null or something to get to 64 character hex string?

This issue is filed as there is an edge case where you may be using another library that does not have .key and .rekey built-in wrapper function and the password may contain quote characters, e.g. " which would break key="somekey" usage when variables are interpolated. True, you could simply escape the quotes, but we were wondering how you might write with this approach:

sqlite> PRAGMA key = "x'2DD29CA851E7B56E4697B0E1F08507293D761A05CE4D1B628663F411A8086D99'";
// this does not work since it's not 64 character hex string
db.pragma(
  `key="x'${Buffer.from('some-string-with-quotes').toString('hex')}'"`
);
@titanism
Copy link
Contributor Author

Related xerial/sqlite-jdbc#579

titanism added a commit to forwardemail/forwardemail.net that referenced this issue Dec 10, 2023
@m4heshd
Copy link
Owner

m4heshd commented Jan 12, 2024

Sorry about the extremely delayed response. Any chance you could create a minimal reproducible repo that fails with the particular error? Time is a luxury for me at the moment.

@m4heshd m4heshd added waiting-author-response ⏳ The issue is blocked till the author responds needs-debugging 🪲 This issue needs debugging to further narrow it down labels Jan 12, 2024
@m4heshd m4heshd closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2024
@m4heshd m4heshd added the stale This issue/PR has been inactive for a long time label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-debugging 🪲 This issue needs debugging to further narrow it down stale This issue/PR has been inactive for a long time waiting-author-response ⏳ The issue is blocked till the author responds
Projects
None yet
Development

No branches or pull requests

2 participants