cryptpadtab

encrypted notes in a browser tab  https://p.ce9e.org/cryptpadtab/
git clone https://git.ce9e.org/cryptpadtab.git

commit
259720414057453059bb4deb2066b29d13650d18
parent
d291c2f5ff8a125d1ec58a73ff8242fe73f4a8ae
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2024-05-29 16:03
view parameter to serve websites

Diffstat

M static/main.js 10 +++++++++-

1 files changed, 9 insertions, 1 deletions


diff --git a/static/main.js b/static/main.js

@@ -1,5 +1,7 @@
    1     1 import * as crypto from './crypto.js';
    2     2 
   -1     3 var params = new URLSearchParams(location.search);
   -1     4 
    3     5 var password = window.prompt('Please enter the password');
    4     6 var key = await crypto.getKey(password);
    5     7 
@@ -7,7 +9,13 @@ var textarea = document.querySelector('textarea');
    7     9 
    8    10 if (location.hash.length) {
    9    11 	try {
   10    -1 		textarea.value = await crypto.decryptText(location.hash.substr(1), key);
   -1    12 		var plaintext = await crypto.decryptText(location.hash.substr(1), key);
   -1    13 		if (params.has('view')) {
   -1    14 			document.write(plaintext);
   -1    15 			document.close();
   -1    16 		} else {
   -1    17 			textarea.value = plaintext;
   -1    18 		}
   11    19 	} catch (e) {
   12    20 		window.confirm('Decryption failed');
   13    21 		console.exception(e);