diff --git a/src/css/button.css b/src/css/button.css index c4337a7c16912e8869769ac5f5ce77e82f321bf0..08ac95565bca3cbdefd0d3399e12f21259a147a2 100644 --- a/src/css/button.css +++ b/src/css/button.css @@ -10,4 +10,18 @@ height: 50px; width: 100px; margin: 10px; +} + +#instTab{ + border: 5px solid powderblue; + height: 50px; + width: 100px; + margin: 10px; +} + +#changeKey{ + border: 5px solid powderblue; + height: 50px; + width: 100px; + margin: 10px; } \ No newline at end of file diff --git a/src/html/popup.html b/src/html/popup.html index 748136f190772e73230f0c322bb14b5358728d91..d93217300d782a2e4446ae746e0098b05a7e9f14 100644 --- a/src/html/popup.html +++ b/src/html/popup.html @@ -13,7 +13,7 @@ </div> <div class="grid-item"> <a href="instructions.html" target="_blank"> - <button> + <button id="instTab"> Instructions </button> </a> diff --git a/src/js/background.js b/src/js/background.js index 401a4d1a420056e894c4e583e40c8c0f61d74881..b35c53e2a523b45652d4f2e5a08954bd60f592f9 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -1,4 +1,3 @@ -let color = '#3aa757'; var cryptojs = require("crypto-js") chrome.runtime.onInstalled.addListener(function() { diff --git a/src/js/popup.js b/src/js/popup.js index e9b0aea796dc463e256224e02478146749ec716d..86c492201c6c11e9b974ada328a6edd2df9ceb94 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -1,4 +1,4 @@ -var crypto = require('crypto-js'); +var cryptojs = require('crypto-js'); var filesaver = require('file-saver'); let encrypt = document.getElementById("encrypt"); let decrypt = document.getElementById("decrypt"); @@ -43,10 +43,10 @@ input_enc.addEventListener("change", () => { var iv = result.iv; // Convert: ArrayBuffer -> WordArray - var wordArray = crypto.lib.WordArray.create(reader.result); + var wordArray = cryptojs.lib.WordArray.create(reader.result); // Encryption: I: WordArray -> O: -> Base64 encoded string (OpenSSL-format) - var encrypted = crypto.AES.encrypt(wordArray, key,{iv: iv}).toString(); + var encrypted = cryptojs.AES.encrypt(wordArray, key,{iv: iv}).toString(); // Create blob from string var fileEnc = new Blob([encrypted]); @@ -88,7 +88,7 @@ input_dec.addEventListener("change", () => { var iv = result.iv; // Decryption: I: Base64 encoded string (OpenSSL-format) -> O: WordArray - var decrypted = crypto.AES.decrypt(reader.result, key,{iv: iv}); + var decrypted = cryptojs.AES.decrypt(reader.result, key,{iv: iv}); // Convert: WordArray -> typed array var typedArray = convertWordArrayToUint8Array(decrypted); @@ -135,5 +135,21 @@ function getUserKey(){ let userKey = window.prompt("Input new encryption key"); if (userKey == null) return; - alert(userKey); + + var vector = cryptojs.lib.WordArray.random(16); + var salt = cryptojs.lib.WordArray.random(128/8); + var newKey = cryptojs.PBKDF2(userKey, salt, { keySize: 256 / 32, iterations: 1000 }); + alert("3"); + + chrome.storage.local.set({iv: vector}, function(){ + alert("New Vector Set"); + }); + + chrome.storage.local.set({key: newKey}, function (){ + alert("New Key Set"); + }); + + chrome.storage.local.get(['key'],function(result) { + alert('Value currently is ' + result.key); + }) } \ No newline at end of file