Skip to content

Commit

Permalink
Changed use_encryption_key to use_password
Browse files Browse the repository at this point in the history
because SQLCipher interprets it as one, i.e. it uses key derivation
  • Loading branch information
snej committed Jul 11, 2024
1 parent 27690ba commit e50c447
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions include/sqnice/database.hh
Original file line number Diff line number Diff line change
Expand Up @@ -442,20 +442,20 @@ namespace sqnice {
static const bool encryption_available;

/// Unlocks an encrypted database, or makes a newly-created database encrypted,
/// by providing the key to use to encrypt/decrypt data.
/// by providing the password to use to encrypt/decrypt data.
///
/// This should be called immediately after opening the database, since no data can be
/// read from an encrypted database without the key, and encryption can't be enabled in
/// a new database once data has been written to it.
/// @note This function requires SQLCipher or the SQLite Encryption Extension.
/// Otherwise it returns/throws status::error.
status use_encryption_key(std::span<const std::byte> key);
status use_password(std::string_view password);

/// Changes the encryption key of an already-encrypted database.
/// Changes the encryption password of an already-encrypted database.
/// Will not encrypt an existing unencrypted database!
/// @note This function requires SQLCipher or the SQLite Encryption Extension.
/// Otherwise it returns/throws status::error.
status rekey(std::span<const std::byte> newKey);
status rekey(std::string_view newPassword);

#pragma mark - LOGGING

Expand Down
8 changes: 4 additions & 4 deletions src/database.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,12 +585,12 @@ namespace sqnice {

const bool database::encryption_available = true;

status database::use_encryption_key(std::span<const std::byte> key) {
return check(sqlite3_key(check_handle(), key.data(), int(key.size())));
status database::use_password(std::string_view password) {
return check(sqlite3_key(check_handle(), password.data(), int(password.size())));
}

status database::rekey(std::span<const std::byte> newKey) {
return check(sqlite3_rekey(check_handle(), newKey.data(), int(newKey.size())));
status database::rekey(std::string_view newPassword) {
return check(sqlite3_rekey(check_handle(), newPassword.data(), int(newPassword.size())));
}

#else
Expand Down

0 comments on commit e50c447

Please sign in to comment.