Strip base64 prefix to not have static data in encrypted content

This commit is contained in:
Jiiks 2018-08-12 20:57:02 +03:00
parent 3b8126781d
commit b24c0ba2f3
2 changed files with 2 additions and 3 deletions

View File

@ -133,7 +133,7 @@ export default new class E2EE extends BuiltinModule {
try {
const decrypt = this.decrypt(this.decrypt(this.decrypt(seed, this.master), haveKey), cached.image);
component.props.className = 'bd-decryptedImage';
component.props.src = component.props.original = decrypt;
component.props.src = component.props.original = 'data:;base64,' + decrypt;
} catch (err) { return } finally { component.props.readyState = 'READY' }
return;
}

View File

@ -68,9 +68,8 @@
const canvas = document.createElement('canvas');
canvas.height = img.height;
canvas.width = img.width;
const arrBuffer = await Utils.canvasToArrayBuffer(canvas);
const encodedBytes = new TextEncoder().encode(E2EE.encrypt(img.src));
const encodedBytes = new TextEncoder().encode(E2EE.encrypt(img.src.replace('data:;base64,', '')));
Uploader.upload(DiscordApi.currentChannel.id, FileActions.makeFile(new Uint8Array([...new Uint8Array(arrBuffer), ...encodedBytes]), 'bde2ee.png'));
},