diff --git a/src/lib/EncryptButton.svelte b/src/lib/EncryptButton.svelte index 856c34e..ded2d3f 100644 --- a/src/lib/EncryptButton.svelte +++ b/src/lib/EncryptButton.svelte @@ -42,7 +42,9 @@ } convertToBase64(file).then((base64) => { encrypt(base64).then((encrypted_content => { - let encrypted_file: Blob = new Blob(encrypted_content, {type: "text/plain"}); + console.log(encrypted_content) + let encrypted_b64: string = btoa(unescape(encodeURIComponent(encrypted_content))); + let encrypted_file: Blob = new Blob([encrypted_b64], {type: "text/plain"}); let url = URL.createObjectURL(encrypted_file); let a = document.createElement("a"); a.href = url; diff --git a/src/lib/cryptlib.ts b/src/lib/cryptlib.ts index afc49b6..a6920e1 100644 --- a/src/lib/cryptlib.ts +++ b/src/lib/cryptlib.ts @@ -71,8 +71,8 @@ export async function encrypt(string: string) { key, encoded ); - console.log(ciphertext) - return ciphertext + let decodedCiphertext = dec.decode(ciphertext); + return decodedCiphertext } diff --git a/src/lib/generalStore.ts b/src/lib/generalStore.ts new file mode 100644 index 0000000..5a27cb0 --- /dev/null +++ b/src/lib/generalStore.ts @@ -0,0 +1,3 @@ +import { writable} from 'svelte/store'; + +export let filename = writable("Encrypted.b64"); \ No newline at end of file diff --git a/src/lib/pwgen.ts b/src/lib/pwgen.ts index 65d8b6d..a37bad8 100644 --- a/src/lib/pwgen.ts +++ b/src/lib/pwgen.ts @@ -10,5 +10,5 @@ function generateRandomString(length: number): string { } const password: string = generateRandomString(16); -export const globalPassword = writable(password); +export let globalPassword = writable(password);