forked from mystiq/hydrogen-web
iv and digest are sent in unpadded base64
This commit is contained in:
parent
e9324ad678
commit
366f3c0bba
1 changed files with 12 additions and 2 deletions
|
@ -69,10 +69,20 @@ export async function encryptAttachment(platform, blob) {
|
||||||
info: {
|
info: {
|
||||||
v: "v2",
|
v: "v2",
|
||||||
key,
|
key,
|
||||||
iv: base64.encode(iv),
|
iv: encodeUnpaddedBase64(iv),
|
||||||
hashes: {
|
hashes: {
|
||||||
sha256: base64.encode(digest)
|
sha256: encodeUnpaddedBase64(digest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encodeUnpaddedBase64(buffer) {
|
||||||
|
const str = base64.encode(buffer);
|
||||||
|
const paddingIdx = str.indexOf("=");
|
||||||
|
if (paddingIdx !== -1) {
|
||||||
|
return str.substr(0, paddingIdx);
|
||||||
|
} else {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue