Take user password and try to open db

This commit is contained in:
Julia Friesel
2018-09-12 08:51:36 +02:00
parent 3d61459f30
commit 34648a3d89
8 changed files with 53 additions and 57 deletions
+8 -12
View File
@@ -1,22 +1,18 @@
// too see stdout / stderr from this process, run
// adb logcat | grep "NODEJS-MOBILE"
const rnBridge = require('rn-bridge')
const bcryptjs = require('bcryptjs')
const crypto = require('crypto')
rnBridge.channel.on('message', (msg) => {
msg = JSON.parse(msg)
if (msg.type === 'request-password-hash') {
const hash = bcryptjs.hashSync(msg.message, 10)
if (msg.type === 'request-SHA512') {
const hash = crypto.createHash('sha256')
hash.update(msg.message)
const result = hash.digest('hex')
console.log(result)
rnBridge.channel.send(JSON.stringify({
type: 'hash',
message: hash
}))
} else if (msg.type === 'request-SHA512') {
// do the thing
} else if (msg.type === 'check-password') {
rnBridge.channel.send(JSON.stringify({
type: 'password-check-result',
message: bcryptjs.compareSync(msg.message.password, msg.message.hash)
type: 'sha512',
message: result
}))
}
})
-11
View File
@@ -1,11 +0,0 @@
{
"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="
}
}
}
+1 -3
View File
@@ -1,6 +1,4 @@
{
"dependencies": {
"bcryptjs": "^2.4.3"
},
"dependencies": {},
"main": "main.js"
}