diff --git a/frontend/src/lib/storage-manager/storage-manager.js b/frontend/src/lib/storage-manager/storage-manager.js index 049caa508..0849ae933 100644 --- a/frontend/src/lib/storage-manager/storage-manager.js +++ b/frontend/src/lib/storage-manager/storage-manager.js @@ -5,7 +5,7 @@ /* global:writable */ import semver from 'semver'; -import sodium from 'sodium-javascript'; +// import sodium from 'sodium-javascript'; import { HttpClient } from '../../services/http-client/http-client'; @@ -460,7 +460,7 @@ export class StorageManager { const enc = this.load('encryption', { ...options, encryption: false }); const requestBody = { type : options.encryption, - length : sodium.crypto_secretbox_KEYBYTES, + length : undefined, // sodium.crypto_secretbox_KEYBYTES, salt : enc.salt, timestamp : enc.timestamp, }; @@ -501,10 +501,10 @@ function encrypt(plaintext, key) { // TODO use const if possible let plaintextB = Buffer.from(plaintext); let cipherB = Buffer.alloc(plaintextB.length + sodium.crypto_secretbox_MACBYTES); - let nonceB = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES); + let nonceB = undefined; // Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES); let keyB = Buffer.from(key); - sodium.crypto_secretbox_easy(cipherB, plaintextB, nonceB, keyB); + // sodium.crypto_secretbox_easy(cipherB, plaintextB, nonceB, keyB); const result = cipherB; console.log('encrypt result', result); @@ -520,11 +520,11 @@ function decrypt(ciphertext, key) { // TODO use const if possible let cipherB = Buffer.from(ciphertext); - let plaintextB = Buffer.alloc(cipherB.length - sodium.crypto_secretbox_MACBYTES); - let nonceB = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES); + let plaintextB = undefined; Buffer.alloc(cipherB.length - sodium.crypto_secretbox_MACBYTES); + let nonceB = undefined; Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES); let keyB = Buffer.from(key); - sodium.crypto_secretbox_open_easy(plaintextB, cipherB, nonceB, keyB); + // sodium.crypto_secretbox_open_easy(plaintextB, cipherB, nonceB, keyB); const result = plaintextB.toString(); console.log('decrypt result', result);