diff --git a/index.html b/index.html index c0d08b9..863184f 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,8 @@ margin: 20px; } - form { + form, + #displform { max-width: 400px; margin: auto; } @@ -67,8 +68,9 @@ function togglePassword() { const passwordInput = document.getElementById('passwordInput'); - const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password'; + const type = (passwordInput.getAttribute('type') === 'password') ? 'text' : 'password'; passwordInput.setAttribute('type', type); + document.querySelector('.view-password').innerText = (type === 'text') ? '🔒' : '👁️'; } async function sendToServer() { @@ -77,7 +79,7 @@ const isEncrypt = document.getElementById('encryptToggle').checked; const endpoint = isEncrypt ? '/encrypt' : '/decrypt'; - const r = await fetch(endpoint, { + fetch(endpoint, { method: 'POST', body: formData, }) @@ -98,17 +100,35 @@ alert("ERROR!"); }); } + + async function getSaltAndIv() { + const response = await fetch('/getsaltandiv', { method: 'POST' }); + const siv = await response.json(); + const el = document.querySelector('#salivdisp'); + el.innerHTML = `IV: ${siv.iv}
Salt: ${siv.salt}`; + } +
+

A Simple File/Text Encryptor

+

Created by ION606

+
+
+
+

OR

+ +

+
+
@@ -121,6 +141,14 @@ + +
+ +
+ +
+
\ No newline at end of file diff --git a/main.js b/main.js index 0c5e4d7..a403026 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,7 @@ import fs, { read } from 'fs'; import express from 'express'; import cors from 'cors'; -import { encrypt, decrypt } from './enc.js'; +import { encrypt, decrypt, encryptInitEnc } from './enc.js'; import bodyParser from 'body-parser'; import multer from 'multer'; import stream from 'stream'; @@ -49,4 +49,6 @@ app.post('/decrypt', upload.single('file'), (req, res) => { }); +app.post('/getsaltandiv', (_, res) => res.send(encryptInitEnc("I'M ENCRYPTED!", 'password'))) + app.listen(PORT, () => console.log(`app listening on port ${PORT}`)); \ No newline at end of file