Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Third Year Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christos Protopapas
Third Year Project
Commits
991590bb
Commit
991590bb
authored
3 years ago
by
Christos Protopapas
Browse files
Options
Downloads
Patches
Plain Diff
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
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/css/button.css
+14
-0
14 additions, 0 deletions
src/css/button.css
src/html/popup.html
+1
-1
1 addition, 1 deletion
src/html/popup.html
src/js/background.js
+0
-1
0 additions, 1 deletion
src/js/background.js
src/js/popup.js
+21
-5
21 additions, 5 deletions
src/js/popup.js
with
36 additions
and
7 deletions
src/css/button.css
+
14
−
0
View file @
991590bb
...
...
@@ -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
This diff is collapsed.
Click to expand it.
src/html/popup.html
+
1
−
1
View file @
991590bb
...
...
@@ -13,7 +13,7 @@
</div>
<div
class=
"grid-item"
>
<a
href=
"instructions.html"
target=
"_blank"
>
<button>
<button
id=
"instTab"
>
Instructions
</button>
</a>
...
...
This diff is collapsed.
Click to expand it.
src/js/background.js
+
0
−
1
View file @
991590bb
let
color
=
'
#3aa757
'
;
var
cryptojs
=
require
(
"
crypto-js
"
)
chrome
.
runtime
.
onInstalled
.
addListener
(
function
()
{
...
...
This diff is collapsed.
Click to expand it.
src/js/popup.js
+
21
−
5
View file @
991590bb
var
crypto
=
require
(
'
crypto-js
'
);
var
crypto
js
=
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
=
crypto
js
.
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
=
crypto
js
.
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
=
crypto
js
.
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment