Skip to content
Snippets Groups Projects
Commit 991590bb authored by Christos Protopapas's avatar Christos Protopapas
Browse files

Added option to change user-input encryption key, instructions to use it

parent 981b60f7
No related branches found
No related tags found
No related merge requests found
......@@ -11,3 +11,17 @@
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
......@@ -13,7 +13,7 @@
</div>
<div class="grid-item">
<a href="instructions.html" target="_blank">
<button>
<button id="instTab">
Instructions
</button>
</a>
......
let color = '#3aa757';
var cryptojs = require("crypto-js")
chrome.runtime.onInstalled.addListener(function() {
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment