Actually use SHA512, not 256

This commit is contained in:
Julia Friesel
2018-09-13 16:52:54 +02:00
parent 34648a3d89
commit f2f0278a1c
2 changed files with 6 additions and 5 deletions
+5 -3
View File
@@ -26,9 +26,11 @@ export default class PasswordPrompt extends Component {
async msg => { async msg => {
msg = JSON.parse(msg) msg = JSON.parse(msg)
if (msg.type === 'sha512') { if (msg.type === 'sha512') {
const key = new Int8Array(64) const hash = msg.message
for (let i = 0; i < msg.message.length; i++) { const key = new Uint8Array(64)
key[i] = msg.message.charCodeAt(i) for (let i = 0; i < key.length; i++) {
const twoDigitHex = hash.slice(i * 2, i * 2 + 2)
key[i] = parseInt(twoDigitHex, 16)
} }
try { try {
await openDbConnection(key) await openDbConnection(key)
+1 -2
View File
@@ -6,10 +6,9 @@ const crypto = require('crypto')
rnBridge.channel.on('message', (msg) => { rnBridge.channel.on('message', (msg) => {
msg = JSON.parse(msg) msg = JSON.parse(msg)
if (msg.type === 'request-SHA512') { if (msg.type === 'request-SHA512') {
const hash = crypto.createHash('sha256') const hash = crypto.createHash('sha512')
hash.update(msg.message) hash.update(msg.message)
const result = hash.digest('hex') const result = hash.digest('hex')
console.log(result)
rnBridge.channel.send(JSON.stringify({ rnBridge.channel.send(JSON.stringify({
type: 'sha512', type: 'sha512',
message: result message: result