now successfully encrypts a file

main
Johannes Bülow 2023-01-03 21:42:19 +01:00
parent 437a74f26f
commit 26b3ba9b4a
4 changed files with 9 additions and 4 deletions

View File

@ -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;

View File

@ -71,8 +71,8 @@ export async function encrypt(string: string) {
key,
encoded
);
console.log(ciphertext)
return ciphertext
let decodedCiphertext = dec.decode(ciphertext);
return decodedCiphertext
}

3
src/lib/generalStore.ts Normal file
View File

@ -0,0 +1,3 @@
import { writable} from 'svelte/store';
export let filename = writable("Encrypted.b64");

View File

@ -10,5 +10,5 @@ function generateRandomString(length: number): string {
}
const password: string = generateRandomString(16);
export const globalPassword = writable(password);
export let globalPassword = writable(password);