HomePhabricator
Diffusion Comm ce5f64f378ba

[native] Expose Olm sha256 via JSI

Description

[native] Expose Olm sha256 via JSI

Summary:
I'm going to need this for calculating the sha256 blob hash for Blob service.
As suggested in one of "Cryptography discussion" threads, I exposed the Olm sha256 via JSI.

I was basing on the official Olm unit test example.

Test Plan:
Called commUtilsModule.sha256() and compared the result with the unit test above:

const helloWorldArray = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x2c, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64]);
const helloWorldHash = commUtilsModule.sha256(helloWorldArray.buffer);
console.log('Actual:\t', helloWorldHash);
console.log('Expected:\t', 'A2daxT/5zRU1zMffzfosRYxSGDcfQY3BNvLRmsH76KU');

Results can be validated via: https://emn178.github.io/online-tools/sha256.html - first use SHA256, then Base64 encode

Reviewers: marcin, atul

Reviewed By: marcin

Subscribers: ashoat, tomek

Differential Revision: https://phab.comm.dev/D7605

Details

Provenance
bartekAuthored on Apr 25 2023, 4:35 AM
Reviewer
marcin
Differential Revision
D7605: [native] Expose Olm sha256 via JSI
Parents
rCOMM3c57f0880e63: [lib] allow missing `messageIDs` while comparing SQLite with `redux-persist`
Branches
Unknown
Tags
Unknown