js_lis 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VirtualKeyboard.js +698 -624
- package/main.js +33 -0
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -1,7 +1,40 @@
|
|
|
1
1
|
import { VirtualKeyboard } from './VirtualKeyboard.js';
|
|
2
2
|
|
|
3
|
+
// Provide simple session-scoped AES crypto utilities backed by CryptoJS (loaded globally via CDN)
|
|
4
|
+
function createSessionCrypto() {
|
|
5
|
+
const sessionKey = CryptoJS.lib.WordArray.random(32); // 256-bit key
|
|
6
|
+
return {
|
|
7
|
+
encrypt(plaintext) {
|
|
8
|
+
const iv = CryptoJS.lib.WordArray.random(16);
|
|
9
|
+
const cipher = CryptoJS.AES.encrypt(plaintext, sessionKey, {
|
|
10
|
+
iv,
|
|
11
|
+
mode: CryptoJS.mode.CBC,
|
|
12
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
13
|
+
});
|
|
14
|
+
const ivHex = CryptoJS.enc.Hex.stringify(iv);
|
|
15
|
+
const ctB64 = cipher.toString();
|
|
16
|
+
return `${ivHex}:${ctB64}`;
|
|
17
|
+
},
|
|
18
|
+
decrypt(payload) {
|
|
19
|
+
if (!payload) return "";
|
|
20
|
+
const [ivHex, ctB64] = String(payload).split(":");
|
|
21
|
+
if (!ivHex || !ctB64) return "";
|
|
22
|
+
const iv = CryptoJS.enc.Hex.parse(ivHex);
|
|
23
|
+
const decrypted = CryptoJS.AES.decrypt(ctB64, sessionKey, {
|
|
24
|
+
iv,
|
|
25
|
+
mode: CryptoJS.mode.CBC,
|
|
26
|
+
padding: CryptoJS.pad.Pkcs7,
|
|
27
|
+
});
|
|
28
|
+
return decrypted.toString(CryptoJS.enc.Utf8);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
3
33
|
window.onload = () => {
|
|
4
34
|
try {
|
|
35
|
+
// Initialize per-page crypto helper
|
|
36
|
+
window.VKCrypto = createSessionCrypto();
|
|
37
|
+
|
|
5
38
|
window.keyboard = new VirtualKeyboard();
|
|
6
39
|
console.log("VirtualKeyboard initialized successfully.");
|
|
7
40
|
} catch (error) {
|