Use nodejs-mobile and bcrypt to generate encryption key, and encrypt db
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
const rnBridge = require('rn-bridge')
|
||||
try {
|
||||
const bcryptjs = require('bcryptjs')
|
||||
|
||||
rnBridge.channel.on('message', (msg) => {
|
||||
msg = JSON.parse(msg)
|
||||
if (msg.type === 'request-hash') {
|
||||
const hash = bcryptjs.hashSync(msg.message, 10)
|
||||
rnBridge.channel.send(JSON.stringify({
|
||||
type: 'hash',
|
||||
message: hash
|
||||
}))
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
rnBridge.channel.send(JSON.stringify(err.message))
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"bcryptjs": {
|
||||
"version": "2.4.3",
|
||||
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
|
||||
"integrity": "sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms="
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"bcryptjs": "^2.4.3"
|
||||
},
|
||||
"main": "main.js"
|
||||
}
|
||||
Reference in New Issue
Block a user