Skip to content

Commit

Permalink
add electron test to unix-sqlcipher
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Jun 18, 2017
1 parent 1ffdc23 commit f9670a8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
27 changes: 27 additions & 0 deletions electron/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script>
// https://github.com/delaballe/node-sqlcipher#usage
// https://coolaj86.com/articles/building-sqlcipher-for-node-js-on-raspberry-pi-2/
'use strict';
var sqlite3 = require('cross-sqlcipher').verbose();
var db = new sqlite3.Database('./test.db');

db.serialize(function() {
db.run("PRAGMA KEY = 'secret'");
db.run("PRAGMA CIPHER = 'aes-128-cbc'");

db.run("DROP TABLE IF EXISTS lorem");
db.run("CREATE TABLE lorem (info TEXT)");

var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (var i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize();

db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
document.write(row.id + ": " + row.info + '<br>');
});
});

db.close();
</script>
12 changes: 12 additions & 0 deletions electron/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let { app, BrowserWindow } = require('electron')
let { join } = require('path')

let win

app.on('ready', () => {
let url = 'file://' + join(__dirname, 'main.html')
win = new BrowserWindow()
win.loadURL(url)

win.openDevTools()
})
13 changes: 13 additions & 0 deletions electron/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "electron-test",
"main": "main.js",
"scripts": {
"rebuild": "electron-rebuild",
"start": "electron ."
},
"devDependencies": {
"cross-sqlcipher": "0.0.2",
"electron": "^1.6.10",
"electron-rebuild": "^1.5.11"
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"scripts": {
"test": "node test",
"nwtest": "nw nw",
"electron-test": "electron electron",
"nwbuild": "npm i --runtime=node-webkit --target=0.12.3 --target_arch=x64",
"preinstall": "node preinstall",
"postinstall": "node postinstall"
Expand Down

0 comments on commit f9670a8

Please sign in to comment.