diff --git a/components/password-prompt.js b/components/password-prompt.js index 4453af6..5ecc5cb 100644 --- a/components/password-prompt.js +++ b/components/password-prompt.js @@ -26,9 +26,11 @@ export default class PasswordPrompt extends Component { async msg => { msg = JSON.parse(msg) if (msg.type === 'sha512') { - const key = new Int8Array(64) - for (let i = 0; i < msg.message.length; i++) { - key[i] = msg.message.charCodeAt(i) + const hash = msg.message + const key = new Uint8Array(64) + for (let i = 0; i < key.length; i++) { + const twoDigitHex = hash.slice(i * 2, i * 2 + 2) + key[i] = parseInt(twoDigitHex, 16) } try { await openDbConnection(key) diff --git a/nodejs-assets/nodejs-project/main.js b/nodejs-assets/nodejs-project/main.js index f986f42..20227c7 100644 --- a/nodejs-assets/nodejs-project/main.js +++ b/nodejs-assets/nodejs-project/main.js @@ -6,10 +6,9 @@ const crypto = require('crypto') rnBridge.channel.on('message', (msg) => { msg = JSON.parse(msg) if (msg.type === 'request-SHA512') { - const hash = crypto.createHash('sha256') + const hash = crypto.createHash('sha512') hash.update(msg.message) const result = hash.digest('hex') - console.log(result) rnBridge.channel.send(JSON.stringify({ type: 'sha512', message: result