Closed kdkul closed 7 years ago
are you both encrypting and decrypting from the same enviroment ?
yeah, i am trying to do both things in a same environment. Plz let me know if you need any other info to get some idea for this issue.
wait a second, encrypting and decrypting are the same thing in this library, you just set it up and you're reads are decrypted and you writes are encrypted, what exactly are you doing ?
Let me explain. I have encrypted my db now i am trying to derive key through password and salt by below method.
db.get('_local/crypto').then(function (doc) { return new Promise(function (resolve, reject) { crypto.pbkdf2(password, doc.salt, doc.iterations, 256/8, doc.digest, function (err, key) { if (err) { return reject(err); } resolve(key); }); }); }).then(function (key) { // you have the key });
I am providing the same password which i have given at the time db encryption here but each and every time i am gettting console error "pbkdf2 is not a function". I debugged and found inside promise, crypto object is there but there is no pbkdf2 function is attached with crypto object.
that example refers to the browserify/nodejs crypto module, not the browser one, so you need to require that library similar to how you got pouchdb and crypto pouch
On Fri, Apr 7, 2017 at 4:27 PM kdkul notifications@github.com wrote:
Let me explain. I have encrypted my db now i am trying to derive key through password and salt by below method.
db.get('_local/crypto').then(function (doc) { return new Promise(function (resolve, reject) { crypto.pbkdf2(password, doc.salt, doc.iterations, 256/8, doc.digest, function (err, key) { if (err) { return reject(err); } resolve(key); }); }); }).then(function (key) { // you have the key });
I am providing the same password which i have given at the time db encryption here but each and every time i am gettting console error "pbkdf2 is not a function". I debugged and found inside promise, crypto object is there but there is no pbkdf2 function is attached with crypto object.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/calvinmetcalf/crypto-pouch/issues/55#issuecomment-292643213, or mute the thread https://github.com/notifications/unsubscribe-auth/ABE4n0WDUuHLTqkmKEeVA69INPfgLvuMks5rtpwggaJpZM4M0_0S .
i have installed pouchdb and crypto-pouch through npm. I am working on a ionic app. also getting same error if i run application in device itself.
at the top of the file put
var crypto = require('crypto');
i am able to encrypt my database successfully, but i am stuck in decryption. I am trying to get key through password but each and every time i am getting error "crypto.pbkdf2 is not a function." Any suggestion/idea for me what could be the possible reason.