Use nodejs-mobile and bcrypt to generate encryption key, and encrypt db

This commit is contained in:
Julia Friesel
2018-09-09 17:15:31 +02:00
parent b7470151b4
commit 4839f95312
12 changed files with 417 additions and 5 deletions
+11
View File
@@ -1,5 +1,6 @@
import React, { Component } from 'react'
import { View, BackHandler } from 'react-native'
import nodejs from 'nodejs-mobile-react-native'
import Header from './header'
import Menu from './menu'
import Home from './home'
@@ -11,6 +12,7 @@ import Settings from './settings'
import Stats from './stats'
import {headerTitles as titles} from './labels'
import setupNotifications from '../lib/notifications'
import { encrypt } from '../db'
const isSymptomView = name => Object.keys(symptomViews).indexOf(name) > -1
@@ -22,6 +24,15 @@ export default class App extends Component {
}
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.handleBackButtonPress)
setupNotifications(this.navigate)
nodejs.start('main.js')
nodejs.channel.addListener(
'message',
msg => {
msg = JSON.parse(msg)
encrypt(msg.message)
},
this
)
}
componentWillUnmount() {
+2 -3
View File
@@ -8,7 +8,7 @@ import {
import { LocalDate, ChronoUnit } from 'js-joda'
import styles from '../styles/index'
import cycleModule from '../lib/cycle'
import { encrypt, getOrCreateCycleDay, bleedingDaysSortedByDate, fillWithMucusDummyData, fillWithCervixDummyData, deleteAll } from '../db'
import { requestHash, getOrCreateCycleDay, bleedingDaysSortedByDate, fillWithMucusDummyData, fillWithCervixDummyData, deleteAll } from '../db'
import {bleedingPrediction as labels} from './labels'
const getCycleDayNumber = cycleModule().getCycleDayNumber
@@ -81,8 +81,7 @@ export default class Home extends Component {
<View style={styles.homeButton}>
<Button
onPress={() => {
console.log('pressed')
encrypt()
requestHash()
}}
title="encrypt, yo">
</Button>