Skip to content

Commit aad4910

Browse files
committed
Decrypt the database using ASIMOV_SIGNAL_KEY.
1 parent 03732cf commit aad4910

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ asimov-signal-reader
3636

3737
## ⚙ Configuration
3838

39-
This module requires no configuration.
39+
### Encryption Key
40+
41+
```bash
42+
export ASIMOV_SIGNAL_KEY=feedc0dedecafbadcafebabecafed00dfeedc0dedecafbadcafebabecafed00d
43+
```
44+
45+
The key must be 64 hexadecimal characters, meaning 32 bytes (256 bits).
4046

4147
## 📚 Reference
4248

src/reader/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ compile_error!("asimov-signal-reader requires the 'std' feature");
66
use asimov_module::{
77
SysexitsError::{self, *},
88
json::SkipNulls,
9+
secrecy::ExposeSecret,
910
};
1011
use clap::Parser;
1112
use clientele::StandardOptions;
@@ -55,8 +56,14 @@ pub fn main() -> Result<SysexitsError, Box<dyn Error>> {
5556
#[cfg(feature = "tracing")]
5657
asimov_module::init_tracing_subscriber(&options.flags).expect("failed to initialize logging");
5758

59+
let key = asimov_module::getenv::var_secret("ASIMOV_SIGNAL_KEY");
60+
5861
let conn = Connection::open(&options.path)?;
5962

63+
if let Some(key) = key {
64+
conn.pragma_update(None, "key", format!("x'{}'", key.expose_secret()))?;
65+
}
66+
6067
let mut stmt = conn.prepare("SELECT id, type, json FROM conversations")?;
6168
let mut rows = stmt.query([])?;
6269

0 commit comments

Comments
 (0)