Skip to content

Commit d87c7e5

Browse files
committed
u
1 parent cd81c32 commit d87c7e5

File tree

3 files changed

+49
-98
lines changed

3 files changed

+49
-98
lines changed

notes/0 note.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
minimal-mod.css csso
2-
mergely 5.1.4
2+
3+
mergely css & js 5.1.4 (prev used 4.3.9)
34
https://github.com/wickedest/Mergely/releases
45

56
qrcodegen 1.8.0 (closure + wwrap)
@@ -8,9 +9,5 @@ https://www.nayuki.io/res/qr-code-generator-library/qrcodegen.js
89
-----
910

1011
NO LONGER NEEDED:
11-
codemirror 5.65.9 (latest is 6.7.1)
12-
https://codemirror.net/docs/changelog/
13-
14-
previously mergely was 4.3.9
15-
12+
codemirror css & js 5.65.9 (latest is 6.7.1)
1613
codemirror/5.65.9/addon/selection/mark-selection.js

notes/info/text-editor-uc.html

Lines changed: 40 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,7 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
15431543
</script>
15441544

15451545
<button
1546-
onclick="encryptText();scrollToTopFully();"
1546+
onclick="encryptText();"
15471547
class="ttClass"
15481548
data-tooltip="(Web Crypto API, AES-GCM) Enter text to encrypt, click Encrypt, then enter a password when
15491549
prompted. A base64 representation of the encrypted data will be
@@ -1553,7 +1553,7 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
15531553
</button>
15541554

15551555
<button
1556-
onclick="decryptText();scrollToTopFully();"
1556+
onclick="decryptText();"
15571557
class="ttClass"
15581558
data-tooltip="Enter text to decrypt, click Decrypt and then when
15591559
prompted, enter the same password as used for
@@ -1588,12 +1588,16 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
15881588
// let encryptedDataOut = window.document.getElementById("encryptedData");
15891589
let encryptedDataOut =
15901590
window.document.getElementById("textMainArea");
1591+
// Prompt for the password
1592+
15911593
const password = window.prompt("Password");
15921594
const encryptedData = await encryptData(data, password);
15931595
encryptedDataOut.value = encryptedData;
15941596
}
15951597

15961598
async function decryptText() {
1599+
// Prompt for the password
1600+
15971601
const password = window.prompt("Password");
15981602
// const encryptedData = window.document.getElementById("encryptedData").value;
15991603
const encryptedData =
@@ -1603,6 +1607,9 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
16031607
window.document.getElementById("textMainArea");
16041608
const decryptedData = await decryptData(encryptedData, password);
16051609
decryptedDataOut.value = decryptedData || "Decryption failed";
1610+
1611+
// added this to scroll back up, but only after prompt has been given, needed for mobile
1612+
scrollToTopFully();
16061613
}
16071614

16081615
const getPasswordKey = (password) =>
@@ -1685,7 +1692,7 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
16851692
</script>
16861693

16871694
<button
1688-
onclick="encryptFileStart();scrollToTopFully();"
1695+
onclick="encryptFileStart();"
16891696
class="ttClass"
16901697
data-tooltip="(Web Crypto API, AES-GCM) Select the File to process. Click Encrypt, then enter a password when
16911698
prompted. An encrypted file of the original will be downloaded. Note: Doesn't work on the Android app."
@@ -1701,7 +1708,7 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
17011708
-->
17021709

17031710
<button
1704-
onclick="decryptFileStart();scrollToTopFully();"
1711+
onclick="decryptFileStart();"
17051712
class="ttClass"
17061713
data-tooltip="Enter text to decrypt, click Decrypt and then when
17071714
prompted, enter the same password as used for
@@ -1712,82 +1719,6 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
17121719

17131720
<!-- -->
17141721

1715-
<div id="operationModeContainer">
1716-
<button
1717-
class="clickbutton"
1718-
id="selectEncrypt"
1719-
type="button"
1720-
onclick="showEncrypt();"
1721-
>
1722-
Encrypt a File
1723-
</button>
1724-
<button
1725-
class="clickbutton"
1726-
id="selectDncrypt"
1727-
type="button"
1728-
onclick="showDecrypt();"
1729-
>
1730-
Decrypt a File
1731-
</button>
1732-
</div>
1733-
1734-
<div id="cypherContainer" class="hidden">
1735-
<table>
1736-
<!--<tr><td>Select File</td><td><input id="selectFile" type="file" aria-label="Select a file"></td><td id="selectFileHint">Select the File you'd like to process.</td></tr>-->
1737-
<tr>
1738-
<td>Password</td>
1739-
<td>
1740-
<input
1741-
id="mainPassword"
1742-
type="password"
1743-
aria-label="Enter password"
1744-
/>
1745-
</td>
1746-
<td id="mainPasswordHint">
1747-
Strong password, minumum length is 8 characters.
1748-
</td>
1749-
</tr>
1750-
<tr id="trConfirmPassword">
1751-
<td>Retype Password</td>
1752-
<td>
1753-
<input
1754-
id="confirmPassword"
1755-
type="password"
1756-
aria-label="Confirm password"
1757-
/>
1758-
</td>
1759-
<td id="confirmPasswordHint">
1760-
Retype your password from above to ensure you didn't mistype
1761-
it.
1762-
</td>
1763-
</tr>
1764-
</table>
1765-
<button
1766-
id="btnEncrypt"
1767-
class="clickbutton green"
1768-
type="button"
1769-
onclick="encryptFile();"
1770-
>
1771-
Encrypt
1772-
</button>
1773-
<button
1774-
id="btnDecrypt"
1775-
class="clickbutton green"
1776-
type="button"
1777-
onclick="decryptFile();"
1778-
>
1779-
Decrypt
1780-
</button>
1781-
<button
1782-
id="btnReload"
1783-
class="clickbutton orange"
1784-
type="button"
1785-
onclick="javascript:location.reload();"
1786-
>
1787-
Reload Page
1788-
</button>
1789-
</div>
1790-
17911722
<script>
17921723
// https://github.com/hazelfazel/Web-Browser-Based-AES-GCM-File-Encryption-Decryption
17931724

@@ -1883,6 +1814,9 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
18831814
);
18841815
}
18851816

1817+
// added this - Global variable to hold the password
1818+
let mainPassword;
1819+
18861820
// added this
18871821
function encryptFileStart() {
18881822
// trigger file upload of button click
@@ -1897,6 +1831,16 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
18971831
reader.onload = function (event) {};
18981832
// do this after upload
18991833
// call the actual encryption
1834+
1835+
// Prompt for the password
1836+
// change all mainPassword.value to just mainPassword
1837+
mainPassword = window.prompt("Password");
1838+
1839+
// added this to scroll back up, but only after prompt has been given, needed for mobile
1840+
scrollToTopFully();
1841+
1842+
//encryptFile();
1843+
// Call the actual encryption with mainPassword as argument
19001844
encryptFile();
19011845

19021846
reader.onerror = function (event) {
@@ -1921,8 +1865,7 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
19211865
//confirmPasswordHint.classList.remove("greenspan");
19221866
//confirmPasswordHint.classList.remove("redspan");
19231867
/*if ( ( mainPassword.value === confirmPassword.value) && ( mainPassword.value !== "" ) && ( mainPassword.value.length >= 8 ) ) {*/
1924-
// added this below, commented out surrounding if clause around this as well as } } else {, had to do this for both encrypt and decrypt
1925-
mainPassword.value = window.prompt("Password");
1868+
// commented out surrounding if clause around this as well as } } else {, had to do this for both encrypt and decrypt
19261869
//confirmPasswordHint.classList.add("greenspan");
19271870
//logContainer.classList.remove("hidden");
19281871
try {
@@ -1939,7 +1882,8 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
19391882
);
19401883
//log.textContent += "\r\nsha-256 hash of plaintext file: " + arr2Hex(hashPlaintext);
19411884
//log.textContent += "\r\nderiving key from password and random salt ...";
1942-
let keyIv = await deriveKeyIv(mainPassword.value, pbkdf2salt);
1885+
//let keyIv = await deriveKeyIv(mainPassword.value, pbkdf2salt);
1886+
let keyIv = await deriveKeyIv(mainPassword, pbkdf2salt);
19431887
//console.log ( "pbkdf2salt: " + btoa(String.fromCharCode.apply(null, pbkdf2salt)) );
19441888
//log.textContent += "\r\npbkdf2salt: " + btoa(String.fromCharCode.apply(null, pbkdf2salt));
19451889
//log.textContent += "\r\nstarting to encrypt ...";
@@ -1993,6 +1937,16 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
19931937
reader.onload = function (event) {};
19941938
// do this after upload
19951939
// call the actual encryption
1940+
1941+
// Prompt for the password
1942+
// change all mainPassword.value to just mainPassword
1943+
mainPassword = window.prompt("Password");
1944+
1945+
// added this to scroll back up, but only after prompt has been given, needed for mobile
1946+
scrollToTopFully();
1947+
1948+
//encryptFile();
1949+
// Call the actual encryption with mainPassword as argument
19961950
decryptFile();
19971951

19981952
reader.onerror = function (event) {
@@ -2017,8 +1971,7 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
20171971
//mainPasswordHint.classList.remove("greenspan");
20181972
//mainPasswordHint.classList.remove("redspan");
20191973
/*if ( ( mainPassword.value !== "") && ( mainPassword.value.length >= 8 ) ) { */
2020-
// added this below, commented out surrounding if clause around this as well as } } else {, had to do this for both encrypt and decrypt
2021-
mainPassword.value = window.prompt("Password");
1974+
// commented out surrounding if clause around this as well as } } else {, had to do this for both encrypt and decrypt
20221975
//mainPasswordHint.classList.add("greenspan");
20231976
//logContainer.classList.remove("hidden");
20241977
try {
@@ -2037,7 +1990,8 @@ <h2 style="margin-top: 4px; margin-bottom: 5px; font-size: 20px">
20371990
//log.textContent += "\r\nderiving key from password and salt provided in encrypted file ...";
20381991
pbkdf2salt = new Uint8Array(file.slice(0, 16));
20391992
let cipher = file.slice(16);
2040-
let keyIv = await deriveKeyIv(mainPassword.value, pbkdf2salt);
1993+
//let keyIv = await deriveKeyIv(mainPassword.value, pbkdf2salt);
1994+
let keyIv = await deriveKeyIv(mainPassword, pbkdf2salt);
20411995
//console.log ( "pbkdf2salt: " + btoa(String.fromCharCode.apply(null, pbkdf2salt)) );
20421996
//log.textContent += "\r\npbkdf2salt: " + btoa(String.fromCharCode.apply(null, pbkdf2salt));
20431997
//log.textContent += "\r\nstarting to decrypt ...";

notes/info/text-editor.html

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)