Skip to content

Commit

Permalink
Merge pull request #364 from jhaals/fix-binary-upload
Browse files Browse the repository at this point in the history
Fix binary upload
  • Loading branch information
jhaals committed Jan 28, 2020
2 parents 4b93248 + 5f7f7ea commit d04c43b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion website/src/DisplaySecret.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DisplaySecret = () => {
const request = await fetch(`${url}/${key}`);
if (request.status === 200) {
const data = await request.json();
const r = await decryptMessage(data.message, password);
const r = await decryptMessage(data.message, password, 'utf8');
setSecret(r.data as string);
setLoading(false);
return;
Expand Down
2 changes: 1 addition & 1 deletion website/src/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Download = () => {
const request = await fetch(`${url}/${key}`);
if (request.status === 200) {
const data = await request.json();
const file = await decryptMessage(data.message, password);
const file = await decryptMessage(data.message, password, 'binary');
saveAs(
new Blob([file.data as string], {
type: 'application/octet-stream',
Expand Down
7 changes: 6 additions & 1 deletion website/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ const post = async (url: string, body: any) => {
return { data: await request.json(), status: request.status };
};

export const decryptMessage = async (data: string, passwords: string) => {
export const decryptMessage = async (
data: string,
passwords: string,
format: 'utf8' | 'binary',
) => {
const r = await openpgp.decrypt({
message: await openpgp.message.readArmored(data),
passwords,
format,
});
return r;
};
Expand Down

0 comments on commit d04c43b

Please sign in to comment.