This commit is contained in:
2020-08-22 18:31:48 +02:00
parent 7750829b39
commit ab4fc8e18a
7 changed files with 535 additions and 49 deletions

View File

@@ -22,7 +22,7 @@ const DecryptionContext = createContext<DecryptionContextType>({
const decrypt = async (privateKey: string, keys: string[], content: string) => {
const armoredKeys = await Promise.all(keys.map(openpgp.key.readArmored));
const message = openpgp.message.fromText(content);
const message = openpgp.message.fromBinary(content);
const encrypted = await openpgp.decrypt({
message,
privateKeys: [...(await openpgp.key.readArmored(privateKey)).keys],
@@ -82,11 +82,12 @@ const DecryptionProvider: React.FC = ({
reader.onabort = addedFile.setFailed,
reader.onerror = addedFile.setFailed,
reader.onload = () => {
console.log('read');
addedFile.setContent(
decrypt(privateKey, keys, reader.result as string),
);
}
reader.readAsText(file)
reader.readAsBinaryString(file);
}, [keys, username]);
return (