Skip to content

Commit

Permalink
Fixing error in the usage of initializations vector
Browse files Browse the repository at this point in the history
  • Loading branch information
jayralencar committed May 5, 2016
1 parent b032c24 commit 58aa547
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change Log
This change log is started in 0.3.2;

## 0.3.5 (2016-05-05)
- Fixing error in the usage of initializations vector

## 0.3.4 (2016-04-28)
- Using algorithm and password in pvDecrypt
- Using algorithm and password in pvEncrypt
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"encrypt",
"decrypt"
],
"version": "0.3.4",
"version": "0.3.5",
"author": {
"name": "Jayr Alencar",
"email": "jayralencarpereira@gmail.com",
Expand All @@ -33,7 +33,7 @@
"url": "git+https://github.com/JayrAlencar/sqlite-cipher.js"
},
"dependencies":{
"sqlite-sync":"*",
"sqlite-sync":"latest",
"crypto-js":"3.1.5"
},
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions sqlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sqlite.prototype.pvDecrypt = function(buffer, algorithm, password){
algorithm = algorithm || this.algorithm;
password = password || this.password;
if(this.iv){
var decipher = crypto.createDecipher(algorithm,password,{iv:this.iv});
var decipher = crypto.createDecipheriv(algorithm,password,this.iv);
}else{
var decipher = crypto.createDecipher(algorithm,password);
}
Expand All @@ -69,7 +69,7 @@ sqlite.prototype.pvEncrypt = function(buffer, algorithm, password){
algorithm = algorithm || this.algorithm;
password = password || this.password;
if(this.iv){
var cipher = crypto.createCipher(algorithm,password, {iv: this.iv});
var cipher = crypto.createCipheriv(algorithm,password, this.iv);
}else{
var cipher = crypto.createCipher(algorithm,password);
}
Expand Down
21 changes: 11 additions & 10 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ var sqlite = require('../sqlite.js'); //requiring
// sqlite.change('test/Database.rec','88560848','myPass','aes-256-ctr','camellia-256-cfb1');

// To use initialization vector
sqlite.iv = '13ewr3iJ';
sqlite.iv = "1234567890123456";
var password = "12345678901234567890123456789012";

//Connecting - (databaseFile, [password], [algorithm])
try{
sqlite.connect('test/Database.rec','myPass','camellia-256-cfb1');
sqlite.connect('test/Database.rec',password,'aes-256-cbc');
}catch(x){
console.log(x)
}
Expand All @@ -30,16 +31,16 @@ function concat(a,b){
}

//Add your function to connection
sqlite.create_function(concat);
// sqlite.create_function(concat);

// Use your function in the SQL
console.log(sqlite.run("SELECT ID , concat(ID, NAME) as concat FROM COMPANYS;"));
// // Use your function in the SQL
// console.log(sqlite.run("SELECT ID , concat(ID, NAME) as concat FROM COMPANYS;"));

//Decrypting database file
sqlite.decrypt("test/Database.rec","test/decrypted.db", 'myPass');
// //Decrypting database file
// sqlite.decrypt("test/Database.rec","test/decrypted.db", 'myPass');

//Encrypting database file
sqlite.encrypt("test/decrypted.db","test/reencrypted.rec", 'myPass',"bf",{iv: "ads343ef"});
// //Encrypting database file
// sqlite.encrypt("test/decrypted.db","test/reencrypted.rec", 'myPass',"bf",{iv: "ads343ef"});

// Closing connection
// // Closing connection
sqlite.close();

0 comments on commit 58aa547

Please sign in to comment.