now successfully encrypts a file
This commit is contained in:
		
							parent
							
								
									437a74f26f
								
							
						
					
					
						commit
						26b3ba9b4a
					
				
					 4 changed files with 9 additions and 4 deletions
				
			
		| 
						 | 
					@ -42,7 +42,9 @@
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    convertToBase64(file).then((base64) => {
 | 
					    convertToBase64(file).then((base64) => {
 | 
				
			||||||
      encrypt(base64).then((encrypted_content => {
 | 
					      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 url = URL.createObjectURL(encrypted_file);
 | 
				
			||||||
      let a = document.createElement("a");
 | 
					      let a = document.createElement("a");
 | 
				
			||||||
      a.href = url;
 | 
					      a.href = url;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,8 +71,8 @@ export async function encrypt(string: string) {
 | 
				
			||||||
    key,
 | 
					    key,
 | 
				
			||||||
    encoded
 | 
					    encoded
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  console.log(ciphertext)
 | 
					  let decodedCiphertext = dec.decode(ciphertext);
 | 
				
			||||||
  return ciphertext
 | 
					  return decodedCiphertext
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										3
									
								
								src/lib/generalStore.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								src/lib/generalStore.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					import { writable} from 'svelte/store';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export let filename = writable("Encrypted.b64");
 | 
				
			||||||
| 
						 | 
					@ -10,5 +10,5 @@ function generateRandomString(length: number): string {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const password: string = generateRandomString(16);
 | 
					const password: string = generateRandomString(16);
 | 
				
			||||||
export const globalPassword = writable(password);
 | 
					export let globalPassword = writable(password);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue