Encryption works using Typescript and the Browsers API directly, creating a File for download doesn't
parent
3cea63a949
commit
85e97bdc9a
|
@ -25,3 +25,5 @@ yarn.lock
|
|||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
|
||||
#src/lib/crypttool.wasm
|
|
@ -34,12 +34,21 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
["svelte-check", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:2.10.3"],\
|
||||
["tslib", "npm:2.4.1"],\
|
||||
["typescript", "patch:typescript@npm%3A4.9.4#~builtin<compat/typescript>::version=4.9.4&hash=d73830"],\
|
||||
["vite", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:4.0.4"]\
|
||||
["vite", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:4.0.4"],\
|
||||
["vite-plugin-top-level-await", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:1.2.2"],\
|
||||
["vite-plugin-wasm", "npm:3.1.1"]\
|
||||
],\
|
||||
"linkType": "SOFT"\
|
||||
}]\
|
||||
]],\
|
||||
["@esbuild/android-arm", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/@esbuild-android-arm-npm-0.15.18-1a5d80ee32/node_modules/@esbuild/android-arm/",\
|
||||
"packageDependencies": [\
|
||||
["@esbuild/android-arm", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}],\
|
||||
["npm:0.16.13", {\
|
||||
"packageLocation": "./.yarn/unplugged/@esbuild-android-arm-npm-0.16.13-1e6cd6c2ee/node_modules/@esbuild/android-arm/",\
|
||||
"packageDependencies": [\
|
||||
|
@ -130,6 +139,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
}]\
|
||||
]],\
|
||||
["@esbuild/linux-loong64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/@esbuild-linux-loong64-npm-0.15.18-7e5f29c057/node_modules/@esbuild/linux-loong64/",\
|
||||
"packageDependencies": [\
|
||||
["@esbuild/linux-loong64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}],\
|
||||
["npm:0.16.13", {\
|
||||
"packageLocation": "./.yarn/unplugged/@esbuild-linux-loong64-npm-0.16.13-472ae3febc/node_modules/@esbuild/linux-loong64/",\
|
||||
"packageDependencies": [\
|
||||
|
@ -342,7 +358,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
["@sveltejs/vite-plugin-svelte", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:2.0.2"],\
|
||||
["@types/svelte", null],\
|
||||
["@types/vite", null],\
|
||||
["debug", "virtual:51e5c91341600e54e16513d0bfffd1a13bbac804187b4b82e8c30866cd07aed7973d178bb0213afa558d943accdf2834755cd9f6265e89d538a32cefc4ab0da5#npm:4.3.4"],\
|
||||
["debug", "virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4"],\
|
||||
["deepmerge", "npm:4.2.2"],\
|
||||
["kleur", "npm:4.1.5"],\
|
||||
["magic-string", "npm:0.27.0"],\
|
||||
|
@ -360,6 +376,115 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-npm-1.3.24-4fe11f4ec9/node_modules/@swc/core/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core", "npm:1.3.24"],\
|
||||
["@swc/core-darwin-arm64", "npm:1.3.24"],\
|
||||
["@swc/core-darwin-x64", "npm:1.3.24"],\
|
||||
["@swc/core-linux-arm-gnueabihf", "npm:1.3.24"],\
|
||||
["@swc/core-linux-arm64-gnu", "npm:1.3.24"],\
|
||||
["@swc/core-linux-arm64-musl", "npm:1.3.24"],\
|
||||
["@swc/core-linux-x64-gnu", "npm:1.3.24"],\
|
||||
["@swc/core-linux-x64-musl", "npm:1.3.24"],\
|
||||
["@swc/core-win32-arm64-msvc", "npm:1.3.24"],\
|
||||
["@swc/core-win32-ia32-msvc", "npm:1.3.24"],\
|
||||
["@swc/core-win32-x64-msvc", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-darwin-arm64", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-darwin-arm64-npm-1.3.24-f9da9229c6/node_modules/@swc/core-darwin-arm64/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-darwin-arm64", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-darwin-x64", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-darwin-x64-npm-1.3.24-8561ac7215/node_modules/@swc/core-darwin-x64/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-darwin-x64", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-linux-arm-gnueabihf", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-linux-arm-gnueabihf-npm-1.3.24-d37149ee08/node_modules/@swc/core-linux-arm-gnueabihf/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-linux-arm-gnueabihf", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-linux-arm64-gnu", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-linux-arm64-gnu-npm-1.3.24-f240cc6fcf/node_modules/@swc/core-linux-arm64-gnu/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-linux-arm64-gnu", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-linux-arm64-musl", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-linux-arm64-musl-npm-1.3.24-52e0704b69/node_modules/@swc/core-linux-arm64-musl/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-linux-arm64-musl", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-linux-x64-gnu", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-linux-x64-gnu-npm-1.3.24-c5f1fe8470/node_modules/@swc/core-linux-x64-gnu/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-linux-x64-gnu", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-linux-x64-musl", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-linux-x64-musl-npm-1.3.24-cd2a918780/node_modules/@swc/core-linux-x64-musl/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-linux-x64-musl", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-win32-arm64-msvc", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-win32-arm64-msvc-npm-1.3.24-2347174825/node_modules/@swc/core-win32-arm64-msvc/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-win32-arm64-msvc", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-win32-ia32-msvc", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-win32-ia32-msvc-npm-1.3.24-0ce18e2acc/node_modules/@swc/core-win32-ia32-msvc/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-win32-ia32-msvc", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@swc/core-win32-x64-msvc", [\
|
||||
["npm:1.3.24", {\
|
||||
"packageLocation": "./.yarn/unplugged/@swc-core-win32-x64-msvc-npm-1.3.24-073aaabd0a/node_modules/@swc/core-win32-x64-msvc/",\
|
||||
"packageDependencies": [\
|
||||
["@swc/core-win32-x64-msvc", "npm:1.3.24"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["@tootallnate/once", [\
|
||||
["npm:2.0.0", {\
|
||||
"packageLocation": "./.yarn/cache/@tootallnate-once-npm-2.0.0-e36cf4f140-ad87447820.zip/node_modules/@tootallnate/once/",\
|
||||
|
@ -420,7 +545,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
"packageLocation": "./.yarn/cache/agent-base-npm-6.0.2-428f325a93-f52b6872cc.zip/node_modules/agent-base/",\
|
||||
"packageDependencies": [\
|
||||
["agent-base", "npm:6.0.2"],\
|
||||
["debug", "virtual:51e5c91341600e54e16513d0bfffd1a13bbac804187b4b82e8c30866cd07aed7973d178bb0213afa558d943accdf2834755cd9f6265e89d538a32cefc4ab0da5#npm:4.3.4"]\
|
||||
["debug", "virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
|
@ -430,7 +555,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
"packageLocation": "./.yarn/cache/agentkeepalive-npm-4.2.1-b86a9fb343-39cb49ed8c.zip/node_modules/agentkeepalive/",\
|
||||
"packageDependencies": [\
|
||||
["agentkeepalive", "npm:4.2.1"],\
|
||||
["debug", "virtual:51e5c91341600e54e16513d0bfffd1a13bbac804187b4b82e8c30866cd07aed7973d178bb0213afa558d943accdf2834755cd9f6265e89d538a32cefc4ab0da5#npm:4.3.4"],\
|
||||
["debug", "virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4"],\
|
||||
["depd", "npm:1.1.2"],\
|
||||
["humanize-ms", "npm:1.2.1"]\
|
||||
],\
|
||||
|
@ -653,7 +778,9 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
["svelte-check", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:2.10.3"],\
|
||||
["tslib", "npm:2.4.1"],\
|
||||
["typescript", "patch:typescript@npm%3A4.9.4#~builtin<compat/typescript>::version=4.9.4&hash=d73830"],\
|
||||
["vite", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:4.0.4"]\
|
||||
["vite", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:4.0.4"],\
|
||||
["vite-plugin-top-level-await", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:1.2.2"],\
|
||||
["vite-plugin-wasm", "npm:3.1.1"]\
|
||||
],\
|
||||
"linkType": "SOFT"\
|
||||
}]\
|
||||
|
@ -666,10 +793,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
],\
|
||||
"linkType": "SOFT"\
|
||||
}],\
|
||||
["virtual:51e5c91341600e54e16513d0bfffd1a13bbac804187b4b82e8c30866cd07aed7973d178bb0213afa558d943accdf2834755cd9f6265e89d538a32cefc4ab0da5#npm:4.3.4", {\
|
||||
"packageLocation": "./.yarn/__virtual__/debug-virtual-a069950015/0/cache/debug-npm-4.3.4-4513954577-3dbad3f94e.zip/node_modules/debug/",\
|
||||
["virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4", {\
|
||||
"packageLocation": "./.yarn/__virtual__/debug-virtual-4488998e89/0/cache/debug-npm-4.3.4-4513954577-3dbad3f94e.zip/node_modules/debug/",\
|
||||
"packageDependencies": [\
|
||||
["debug", "virtual:51e5c91341600e54e16513d0bfffd1a13bbac804187b4b82e8c30866cd07aed7973d178bb0213afa558d943accdf2834755cd9f6265e89d538a32cefc4ab0da5#npm:4.3.4"],\
|
||||
["debug", "virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4"],\
|
||||
["@types/supports-color", null],\
|
||||
["ms", "npm:2.1.2"],\
|
||||
["supports-color", null]\
|
||||
|
@ -764,6 +891,35 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
}]\
|
||||
]],\
|
||||
["esbuild", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-npm-0.15.18-61e07796c8/node_modules/esbuild/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild", "npm:0.15.18"],\
|
||||
["@esbuild/android-arm", "npm:0.15.18"],\
|
||||
["@esbuild/linux-loong64", "npm:0.15.18"],\
|
||||
["esbuild-android-64", "npm:0.15.18"],\
|
||||
["esbuild-android-arm64", "npm:0.15.18"],\
|
||||
["esbuild-darwin-64", "npm:0.15.18"],\
|
||||
["esbuild-darwin-arm64", "npm:0.15.18"],\
|
||||
["esbuild-freebsd-64", "npm:0.15.18"],\
|
||||
["esbuild-freebsd-arm64", "npm:0.15.18"],\
|
||||
["esbuild-linux-32", "npm:0.15.18"],\
|
||||
["esbuild-linux-64", "npm:0.15.18"],\
|
||||
["esbuild-linux-arm", "npm:0.15.18"],\
|
||||
["esbuild-linux-arm64", "npm:0.15.18"],\
|
||||
["esbuild-linux-mips64le", "npm:0.15.18"],\
|
||||
["esbuild-linux-ppc64le", "npm:0.15.18"],\
|
||||
["esbuild-linux-riscv64", "npm:0.15.18"],\
|
||||
["esbuild-linux-s390x", "npm:0.15.18"],\
|
||||
["esbuild-netbsd-64", "npm:0.15.18"],\
|
||||
["esbuild-openbsd-64", "npm:0.15.18"],\
|
||||
["esbuild-sunos-64", "npm:0.15.18"],\
|
||||
["esbuild-windows-32", "npm:0.15.18"],\
|
||||
["esbuild-windows-64", "npm:0.15.18"],\
|
||||
["esbuild-windows-arm64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}],\
|
||||
["npm:0.16.13", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-npm-0.16.13-f76c8487f8/node_modules/esbuild/",\
|
||||
"packageDependencies": [\
|
||||
|
@ -794,6 +950,186 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-android-64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-android-64-npm-0.15.18-97400e1085/node_modules/esbuild-android-64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-android-64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-android-arm64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-android-arm64-npm-0.15.18-e0ae9fe181/node_modules/esbuild-android-arm64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-android-arm64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-darwin-64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-darwin-64-npm-0.15.18-c3c12de20e/node_modules/esbuild-darwin-64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-darwin-64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-darwin-arm64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-darwin-arm64-npm-0.15.18-37bdbfa731/node_modules/esbuild-darwin-arm64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-darwin-arm64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-freebsd-64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-freebsd-64-npm-0.15.18-11e301bd31/node_modules/esbuild-freebsd-64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-freebsd-64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-freebsd-arm64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-freebsd-arm64-npm-0.15.18-2a54a732b7/node_modules/esbuild-freebsd-arm64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-freebsd-arm64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-linux-32", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-linux-32-npm-0.15.18-7bb0e9887d/node_modules/esbuild-linux-32/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-linux-32", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-linux-64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-linux-64-npm-0.15.18-b7675c5a72/node_modules/esbuild-linux-64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-linux-64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-linux-arm", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-linux-arm-npm-0.15.18-f873f51c2a/node_modules/esbuild-linux-arm/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-linux-arm", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-linux-arm64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-linux-arm64-npm-0.15.18-16f8e6f421/node_modules/esbuild-linux-arm64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-linux-arm64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-linux-mips64le", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-linux-mips64le-npm-0.15.18-098def652e/node_modules/esbuild-linux-mips64le/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-linux-mips64le", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-linux-ppc64le", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-linux-ppc64le-npm-0.15.18-f7486f784a/node_modules/esbuild-linux-ppc64le/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-linux-ppc64le", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-linux-riscv64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-linux-riscv64-npm-0.15.18-75646f6aa3/node_modules/esbuild-linux-riscv64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-linux-riscv64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-linux-s390x", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-linux-s390x-npm-0.15.18-08b5a4f7e0/node_modules/esbuild-linux-s390x/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-linux-s390x", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-netbsd-64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-netbsd-64-npm-0.15.18-196750ec64/node_modules/esbuild-netbsd-64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-netbsd-64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-openbsd-64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-openbsd-64-npm-0.15.18-b19c84d158/node_modules/esbuild-openbsd-64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-openbsd-64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-sunos-64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-sunos-64-npm-0.15.18-0558720f39/node_modules/esbuild-sunos-64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-sunos-64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-windows-32", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-windows-32-npm-0.15.18-1a66313508/node_modules/esbuild-windows-32/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-windows-32", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-windows-64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-windows-64-npm-0.15.18-f926268f42/node_modules/esbuild-windows-64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-windows-64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["esbuild-windows-arm64", [\
|
||||
["npm:0.15.18", {\
|
||||
"packageLocation": "./.yarn/unplugged/esbuild-windows-arm64-npm-0.15.18-ca93639f32/node_modules/esbuild-windows-arm64/",\
|
||||
"packageDependencies": [\
|
||||
["esbuild-windows-arm64", "npm:0.15.18"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["fast-glob", [\
|
||||
["npm:3.2.12", {\
|
||||
"packageLocation": "./.yarn/cache/fast-glob-npm-3.2.12-162763bbae-0b1990f6ce.zip/node_modules/fast-glob/",\
|
||||
|
@ -964,7 +1300,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
["http-proxy-agent", "npm:5.0.0"],\
|
||||
["@tootallnate/once", "npm:2.0.0"],\
|
||||
["agent-base", "npm:6.0.2"],\
|
||||
["debug", "virtual:51e5c91341600e54e16513d0bfffd1a13bbac804187b4b82e8c30866cd07aed7973d178bb0213afa558d943accdf2834755cd9f6265e89d538a32cefc4ab0da5#npm:4.3.4"]\
|
||||
["debug", "virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
|
@ -975,7 +1311,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
"packageDependencies": [\
|
||||
["https-proxy-agent", "npm:5.0.1"],\
|
||||
["agent-base", "npm:6.0.2"],\
|
||||
["debug", "virtual:51e5c91341600e54e16513d0bfffd1a13bbac804187b4b82e8c30866cd07aed7973d178bb0213afa558d943accdf2834755cd9f6265e89d538a32cefc4ab0da5#npm:4.3.4"]\
|
||||
["debug", "virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
|
@ -1660,6 +1996,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
}]\
|
||||
]],\
|
||||
["rollup", [\
|
||||
["npm:2.79.1", {\
|
||||
"packageLocation": "./.yarn/cache/rollup-npm-2.79.1-94e707a9a3-6a2bf167b3.zip/node_modules/rollup/",\
|
||||
"packageDependencies": [\
|
||||
["rollup", "npm:2.79.1"],\
|
||||
["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=df0bf1"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}],\
|
||||
["npm:3.9.1", {\
|
||||
"packageLocation": "./.yarn/cache/rollup-npm-3.9.1-056f766756-929cfab6b8.zip/node_modules/rollup/",\
|
||||
"packageDependencies": [\
|
||||
|
@ -1774,7 +2118,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
"packageDependencies": [\
|
||||
["socks-proxy-agent", "npm:7.0.0"],\
|
||||
["agent-base", "npm:6.0.2"],\
|
||||
["debug", "virtual:51e5c91341600e54e16513d0bfffd1a13bbac804187b4b82e8c30866cd07aed7973d178bb0213afa558d943accdf2834755cd9f6265e89d538a32cefc4ab0da5#npm:4.3.4"],\
|
||||
["debug", "virtual:b86a9fb34323a98c6519528ed55faa0d9b44ca8879307c0b29aa384bde47ff59a7d0c9051b31246f14521dfb71ba3c5d6d0b35c29fffc17bf875aa6ad977d9e8#npm:4.3.4"],\
|
||||
["socks", "npm:2.7.1"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
|
@ -2074,6 +2418,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
}]\
|
||||
]],\
|
||||
["vite", [\
|
||||
["npm:3.2.5", {\
|
||||
"packageLocation": "./.yarn/cache/vite-npm-3.2.5-f23b9ecb5b-ad35b7008c.zip/node_modules/vite/",\
|
||||
"packageDependencies": [\
|
||||
["vite", "npm:3.2.5"]\
|
||||
],\
|
||||
"linkType": "SOFT"\
|
||||
}],\
|
||||
["npm:4.0.4", {\
|
||||
"packageLocation": "./.yarn/cache/vite-npm-4.0.4-33a47fc7a2-eb86c8cdfe.zip/node_modules/vite/",\
|
||||
"packageDependencies": [\
|
||||
|
@ -2116,6 +2467,75 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
|||
"terser"\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}],\
|
||||
["virtual:fe2ad387dd7b87d0cd6e1dc32be298837094e344405d34a972448d46f82e75a9ce074b4504c174fe26d0a0900d5f61fb950cb6fd7deb92860f2165715d827db1#npm:3.2.5", {\
|
||||
"packageLocation": "./.yarn/__virtual__/vite-virtual-c2beea0549/0/cache/vite-npm-3.2.5-f23b9ecb5b-ad35b7008c.zip/node_modules/vite/",\
|
||||
"packageDependencies": [\
|
||||
["vite", "virtual:fe2ad387dd7b87d0cd6e1dc32be298837094e344405d34a972448d46f82e75a9ce074b4504c174fe26d0a0900d5f61fb950cb6fd7deb92860f2165715d827db1#npm:3.2.5"],\
|
||||
["@types/less", null],\
|
||||
["@types/node", null],\
|
||||
["@types/sass", null],\
|
||||
["@types/stylus", null],\
|
||||
["@types/sugarss", null],\
|
||||
["@types/terser", null],\
|
||||
["esbuild", "npm:0.15.18"],\
|
||||
["fsevents", "patch:fsevents@npm%3A2.3.2#~builtin<compat/fsevents>::version=2.3.2&hash=df0bf1"],\
|
||||
["less", null],\
|
||||
["postcss", "npm:8.4.20"],\
|
||||
["resolve", "patch:resolve@npm%3A1.22.1#~builtin<compat/resolve>::version=1.22.1&hash=c3c19d"],\
|
||||
["rollup", "npm:2.79.1"],\
|
||||
["sass", null],\
|
||||
["stylus", null],\
|
||||
["sugarss", null],\
|
||||
["terser", null]\
|
||||
],\
|
||||
"packagePeers": [\
|
||||
"@types/less",\
|
||||
"@types/node",\
|
||||
"@types/sass",\
|
||||
"@types/stylus",\
|
||||
"@types/sugarss",\
|
||||
"@types/terser",\
|
||||
"less",\
|
||||
"sass",\
|
||||
"stylus",\
|
||||
"sugarss",\
|
||||
"terser"\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["vite-plugin-top-level-await", [\
|
||||
["npm:1.2.2", {\
|
||||
"packageLocation": "./.yarn/cache/vite-plugin-top-level-await-npm-1.2.2-b043a62870-cd745d2dab.zip/node_modules/vite-plugin-top-level-await/",\
|
||||
"packageDependencies": [\
|
||||
["vite-plugin-top-level-await", "npm:1.2.2"]\
|
||||
],\
|
||||
"linkType": "SOFT"\
|
||||
}],\
|
||||
["virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:1.2.2", {\
|
||||
"packageLocation": "./.yarn/__virtual__/vite-plugin-top-level-await-virtual-4ded49bbcb/0/cache/vite-plugin-top-level-await-npm-1.2.2-b043a62870-cd745d2dab.zip/node_modules/vite-plugin-top-level-await/",\
|
||||
"packageDependencies": [\
|
||||
["vite-plugin-top-level-await", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:1.2.2"],\
|
||||
["@swc/core", "npm:1.3.24"],\
|
||||
["@types/vite", null],\
|
||||
["vite", "virtual:65c243a0166dd3801f65050c36b40a1ee2e4ea102311ca478f570efa3bfddf1a57d064108fbd02bdf9c92cfbf4cc7da022f91665b1650ca5657618c484153929#npm:4.0.4"]\
|
||||
],\
|
||||
"packagePeers": [\
|
||||
"@types/vite",\
|
||||
"vite"\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["vite-plugin-wasm", [\
|
||||
["npm:3.1.1", {\
|
||||
"packageLocation": "./.yarn/cache/vite-plugin-wasm-npm-3.1.1-fe2ad387dd-a28734af25.zip/node_modules/vite-plugin-wasm/",\
|
||||
"packageDependencies": [\
|
||||
["vite-plugin-wasm", "npm:3.1.1"],\
|
||||
["vite", "virtual:fe2ad387dd7b87d0cd6e1dc32be298837094e344405d34a972448d46f82e75a9ce074b4504c174fe26d0a0900d5f61fb950cb6fd7deb92860f2165715d827db1#npm:3.2.5"]\
|
||||
],\
|
||||
"linkType": "HARD"\
|
||||
}]\
|
||||
]],\
|
||||
["vitefu", [\
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"svelte.svelte-vscode",
|
||||
"rust-lang.rust-analyzer",
|
||||
"ms-vscode.makefile-tools",
|
||||
"dtsvet.vscode-wasm"
|
||||
"dtsvet.vscode-wasm",
|
||||
"bungcip.better-toml"
|
||||
]
|
||||
}
|
||||
|
|
16
Makefile
16
Makefile
|
@ -1,4 +1,5 @@
|
|||
JSPKGMANi = "yarn"
|
||||
JSPKGMAN = "yarn"
|
||||
ROOTDIR = $(dir $(CURDIR))
|
||||
|
||||
dev:
|
||||
$(JSPKGMAN) run vite dev
|
||||
|
@ -6,5 +7,16 @@ dev:
|
|||
test:
|
||||
$(JSPKGMAN) run vite check
|
||||
|
||||
build:
|
||||
build: wasm-build
|
||||
$(JSPKGMAN) run vite build
|
||||
|
||||
wasm-pack:
|
||||
wasm-pack build $(CURDIR)/wasm --target web
|
||||
cp $(CURDIR)/wasm/pkg/crypttool_wasm_bg.wasm $(CURDIR)/src/lib/crypttool.wasm
|
||||
|
||||
#TODO get rid of -f and check whether files exist instead
|
||||
clean:
|
||||
rm -f $(CURDIR)/src/lib/crypttool.wasm
|
||||
rm -rf $(CURDIR)/wasm/pkg/*
|
||||
rm -rf $(CURDIR)/wasm/target/*
|
||||
rm -rf $(CURDIR)/node_modules/*
|
51
README.md
51
README.md
|
@ -1,47 +1,6 @@
|
|||
# Svelte + TS + Vite
|
||||
# Crypttool
|
||||
## A website to encrypt and decrypt files offline in the Browser
|
||||
This Project is more of a proof of concept than an actually useful Application, but it essentially wants to solve the Issue of sending and recieving encrypted Files via E-Mail or other means.
|
||||
The Idea of this Project is to do all of the Encryption client-side using Javascript or WebAssembly, so the Website will work without any Server and can be packaged as a single html file and distributed this way.
|
||||
|
||||
This template should help get you started developing with Svelte and TypeScript in Vite.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
|
||||
|
||||
## Need an official Svelte framework?
|
||||
|
||||
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
|
||||
|
||||
## Technical considerations
|
||||
|
||||
**Why use this over SvelteKit?**
|
||||
|
||||
- It brings its own routing solution which might not be preferable for some users.
|
||||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
|
||||
|
||||
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
|
||||
|
||||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
|
||||
|
||||
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
|
||||
|
||||
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
|
||||
|
||||
**Why include `.vscode/extensions.json`?**
|
||||
|
||||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
|
||||
|
||||
**Why enable `allowJs` in the TS template?**
|
||||
|
||||
While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.
|
||||
|
||||
**Why is HMR not preserving my local component state?**
|
||||
|
||||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
|
||||
|
||||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
|
||||
|
||||
```ts
|
||||
// store.ts
|
||||
// An extremely simple external store
|
||||
import { writable } from 'svelte/store'
|
||||
export default writable(0)
|
||||
```
|
||||
Ideally, I would like for this to be able to en/decrypt any content. A nice to have Feature would be to make it work in a "self-extracting" way, so you could basically generate a html file that prompts you for a password and decrypts its content.
|
|
@ -0,0 +1,47 @@
|
|||
# Svelte + TS + Vite
|
||||
|
||||
This template should help get you started developing with Svelte and TypeScript in Vite.
|
||||
|
||||
## Recommended IDE Setup
|
||||
|
||||
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
|
||||
|
||||
## Need an official Svelte framework?
|
||||
|
||||
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
|
||||
|
||||
## Technical considerations
|
||||
|
||||
**Why use this over SvelteKit?**
|
||||
|
||||
- It brings its own routing solution which might not be preferable for some users.
|
||||
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
|
||||
|
||||
This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
|
||||
|
||||
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
|
||||
|
||||
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
|
||||
|
||||
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
|
||||
|
||||
**Why include `.vscode/extensions.json`?**
|
||||
|
||||
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
|
||||
|
||||
**Why enable `allowJs` in the TS template?**
|
||||
|
||||
While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.
|
||||
|
||||
**Why is HMR not preserving my local component state?**
|
||||
|
||||
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).
|
||||
|
||||
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
|
||||
|
||||
```ts
|
||||
// store.ts
|
||||
// An extremely simple external store
|
||||
import { writable } from 'svelte/store'
|
||||
export default writable(0)
|
||||
```
|
|
@ -4,6 +4,7 @@
|
|||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"wasm": "wasm-pack build ./wasm --target web",
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
|
@ -16,6 +17,8 @@
|
|||
"svelte-check": "^2.10.0",
|
||||
"tslib": "^2.4.1",
|
||||
"typescript": "^4.9.3",
|
||||
"vite": "^4.0.0"
|
||||
"vite": "^4.0.4",
|
||||
"vite-plugin-top-level-await": "^1.2.2",
|
||||
"vite-plugin-wasm": "^3.1.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import EncryptButton from './lib/EncryptButton.svelte'
|
||||
import PasswordGenerator from './lib/PasswordGenerator.svelte';
|
||||
import PasswordButton from './lib/PasswordButton.svelte';
|
||||
</script>
|
||||
|
||||
<main>
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
<div class="card">
|
||||
Password:
|
||||
<PasswordGenerator />
|
||||
<PasswordButton />
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
//import { globalPassword } from './PasswordGenerator.svelte';
|
||||
import { globalPassword } from './pwgen';
|
||||
import { encrypt } from './cryptlib';
|
||||
|
||||
function convertToBase64(file: File): Promise<string> {
|
||||
let password;
|
||||
globalPassword.subscribe(value => {
|
||||
password = value;
|
||||
})
|
||||
|
||||
|
||||
function convertToBase64(blob: Blob): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (event: ProgressEvent<FileReader>) => {
|
||||
|
@ -12,12 +19,13 @@
|
|||
console.log(error)
|
||||
reject(error);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
reader.readAsDataURL(blob);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let file: File | undefined;
|
||||
|
||||
let file: Blob | undefined;
|
||||
|
||||
function handleDrop(event: DragEvent) {
|
||||
event.preventDefault();
|
||||
|
@ -27,19 +35,36 @@
|
|||
|
||||
async function handleSubmit(event: Event) {
|
||||
event.preventDefault();
|
||||
console.log(file)
|
||||
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
convertToBase64(file).then((base64) => {
|
||||
// Do something with the base64-encoded string
|
||||
});
|
||||
encrypt(base64).then((encrypted_content => {
|
||||
let encrypted_file: Blob = new Blob(encrypted_content, {type: "text/plain"});
|
||||
let url = URL.createObjectURL(encrypted_file);
|
||||
let a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = "Encrypted.txt";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
}));
|
||||
})
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<form on:submit|preventDefault={handleSubmit}>
|
||||
<div
|
||||
class="upload-button"
|
||||
on:dragenter|preventDefault
|
||||
on:dragover|preventDefault
|
||||
on:drop|preventDefault={handleDrop}
|
||||
>
|
||||
Drag and drop a file here to upload
|
||||
</div>
|
||||
<button type="submit">Encrypt</button>
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<script lang=ts>
|
||||
import { globalPassword } from "./pwgen";
|
||||
let password;
|
||||
|
||||
globalPassword.subscribe(value => {
|
||||
password = value;
|
||||
})
|
||||
|
||||
|
||||
function copyToClipboard() {
|
||||
navigator.clipboard.writeText(password).then(
|
||||
function() {
|
||||
console.log('Text copied to clipboard', password);
|
||||
},
|
||||
function(err) {
|
||||
console.error('Error copying text to clipboard: ', err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<button on:click={copyToClipboard}>{password}</button>
|
|
@ -1,30 +0,0 @@
|
|||
<script lang=ts>
|
||||
import { readable, type Readable } from 'svelte/store';
|
||||
|
||||
function generateRandomString(length: number): string {
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
const charCode = Math.floor(Math.random() * 62);
|
||||
result += String.fromCharCode(charCode + (charCode < 26 ? 65 : (charCode < 52 ? 71 : -4)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const password: string = generateRandomString(16);
|
||||
export const globalPassword = readable(password);
|
||||
|
||||
|
||||
function copyToClipboard() {
|
||||
navigator.clipboard.writeText(password).then(
|
||||
function() {
|
||||
console.log('Text copied to clipboard', password);
|
||||
},
|
||||
function(err) {
|
||||
console.error('Error copying text to clipboard: ', err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<button on:click={copyToClipboard}>{password}</button>
|
|
@ -0,0 +1,108 @@
|
|||
//import crypto from 'crypto'
|
||||
import { globalPassword } from './pwgen';
|
||||
let password: string;
|
||||
let salt;
|
||||
let ciphertext;
|
||||
let iv;
|
||||
globalPassword.subscribe(value => {
|
||||
password = value;
|
||||
})
|
||||
|
||||
/*
|
||||
Fetch the contents of the "message" textbox, and encode it
|
||||
in a form we can use for the encrypt operation.
|
||||
*/
|
||||
function getStringEncoding(string: string) {
|
||||
let enc = new TextEncoder();
|
||||
return enc.encode(string);
|
||||
}
|
||||
/*
|
||||
Get some key material to use as input to the deriveKey method.
|
||||
The key material is a password supplied by the user.
|
||||
*/
|
||||
function getKeyMaterial() {
|
||||
let enc = new TextEncoder();
|
||||
return window.crypto.subtle.importKey(
|
||||
"raw",
|
||||
enc.encode(password),
|
||||
{name: "PBKDF2"},
|
||||
false,
|
||||
["deriveBits", "deriveKey"]
|
||||
);
|
||||
}
|
||||
/*
|
||||
Given some key material and some random salt
|
||||
derive an AES-GCM key using PBKDF2.
|
||||
*/
|
||||
function getKey(keyMaterial, salt) {
|
||||
return window.crypto.subtle.deriveKey(
|
||||
{
|
||||
"name": "PBKDF2",
|
||||
salt: salt,
|
||||
"iterations": 100000,
|
||||
"hash": "SHA-256"
|
||||
},
|
||||
keyMaterial,
|
||||
{ "name": "AES-GCM", "length": 256},
|
||||
true,
|
||||
[ "encrypt", "decrypt" ]
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
Derive a key from a password supplied by the user, and use the key
|
||||
to encrypt the message.
|
||||
Update the "ciphertextValue" box with a representation of part of
|
||||
the ciphertext.
|
||||
*/
|
||||
export async function encrypt(string: string) {
|
||||
let dec = new TextDecoder();
|
||||
let keyMaterial = await getKeyMaterial();
|
||||
salt = window.crypto.getRandomValues(new Uint8Array(16));
|
||||
let key = await getKey(keyMaterial, salt);
|
||||
iv = window.crypto.getRandomValues(new Uint8Array(12));
|
||||
let encoded = getStringEncoding(string);
|
||||
|
||||
ciphertext = await window.crypto.subtle.encrypt(
|
||||
{
|
||||
name: "AES-GCM",
|
||||
iv: iv
|
||||
},
|
||||
key,
|
||||
encoded
|
||||
);
|
||||
console.log(ciphertext)
|
||||
return ciphertext
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Derive a key from a password supplied by the user, and use the key
|
||||
to decrypt the ciphertext.
|
||||
If the ciphertext was decrypted successfully,
|
||||
update the "decryptedValue" box with the decrypted value.
|
||||
If there was an error decrypting,
|
||||
update the "decryptedValue" box with an error message.
|
||||
*/
|
||||
export async function decrypt(string: string) {
|
||||
let keyMaterial = await getKeyMaterial();
|
||||
let key = await getKey(keyMaterial, salt);
|
||||
|
||||
try {
|
||||
let decrypted = await window.crypto.subtle.decrypt(
|
||||
{
|
||||
name: "AES-GCM",
|
||||
iv: iv
|
||||
},
|
||||
key,
|
||||
ciphertext
|
||||
);
|
||||
|
||||
let dec = new TextDecoder();
|
||||
return dec.decode(decrypted);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
return `Decryption error: ${e}`
|
||||
}
|
||||
}
|
||||
// Hacked together version of https://github.com/mdn/dom-examples/blob/main/web-crypto/derive-key/pbkdf2.jshttps://gist.github.com/ChaoLiangSuper/0e13f77712b68682f0d8ebabb2d63aa8
|
|
@ -0,0 +1,14 @@
|
|||
import { writable} from 'svelte/store';
|
||||
|
||||
function generateRandomString(length: number): string {
|
||||
let result = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
const charCode = Math.floor(Math.random() * 62);
|
||||
result += String.fromCharCode(charCode + (charCode < 26 ? 65 : (charCode < 52 ? 71 : -4)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const password: string = generateRandomString(16);
|
||||
export const globalPassword = writable(password);
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
import { defineConfig } from 'vite';
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||
import wasm from "vite-plugin-wasm";
|
||||
import topLevelAwait from "vite-plugin-top-level-await";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
plugins: [svelte(), wasm(), topLevelAwait()],
|
||||
})
|
||||
|
|
|
@ -0,0 +1,336 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aes"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cipher",
|
||||
"cpufeatures",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-modes"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-padding"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc-any"
|
||||
version = "2.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "774646b687f63643eb0f4bf13dc263cb581c8c9e57973b6ddf78bda3994d88df"
|
||||
dependencies = [
|
||||
"debug-helper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypttool-wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"magic-crypt",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "debug-helper"
|
||||
version = "0.3.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f578e8e2c440e7297e008bb5486a3a8a194775224bbc23729b0dbdfaeebf162e"
|
||||
|
||||
[[package]]
|
||||
name = "des"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac41dd49fb554432020d52c875fc290e110113f864c6b1b525cd62c7e7747a5d"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"cipher",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.139"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "magic-crypt"
|
||||
version = "3.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0196bd5c76f5f51d7d6563545f86262fef4c82d75466ba6f6d359c40a523318d"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"base64",
|
||||
"block-modes",
|
||||
"crc-any",
|
||||
"des",
|
||||
"digest",
|
||||
"md-5",
|
||||
"sha2",
|
||||
"tiger",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "md-5"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"digest",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.49"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.9.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiger"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "443e531cbcf9de83258cfef70bcd56c91188de5819ebd4b19c85f589e0617005"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"byteorder",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
"once_cell",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
|
@ -1,8 +1,23 @@
|
|||
[package]
|
||||
name = "wasm"
|
||||
name = "crypttool-wasm"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = "0.2"
|
||||
magic-crypt = "3.1.12"
|
||||
|
||||
[dependencies.web-sys]
|
||||
version = "*"
|
||||
features = [
|
||||
'Document',
|
||||
'Element',
|
||||
'HtmlElement',
|
||||
'Node',
|
||||
'Window',
|
||||
]
|
|
@ -1,14 +1,18 @@
|
|||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
use wasm_bindgen::prelude::*;
|
||||
use magic_crypt::{new_magic_crypt, MagicCryptTrait};
|
||||
|
||||
// Hacky implementation for a wasm file to en- and decrypt files
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn encrypt(password: &str, plain_base64: &str) -> String {
|
||||
let crypt = new_magic_crypt!(password, 256);
|
||||
let encrypted_base64 = crypt.encrypt_str_to_base64(plain_base64);
|
||||
return encrypted_base64;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
#[wasm_bindgen]
|
||||
pub fn decrypt(password: &str, encrypted_base64: &str) -> String {
|
||||
let crypt = new_magic_crypt!(password, 256);
|
||||
let plain_base64 = crypt.decrypt_base64_to_string(encrypted_base64);
|
||||
return plain_base64.unwrap();
|
||||
}
|
Loading…
Reference in New Issue