mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-05-26 14:06:30 +00:00
34e3d30c78
* smp web: protocol encodings and x3dh * fix * strnup761 compiled to wasm * AES-256-GCM, comatibility tests * core of double ratchet * PQ double ratchet * test typescript ratchets * agent encoding/encryption stack with test --------- Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
15 lines
398 B
JavaScript
15 lines
398 B
JavaScript
addToLibrary({
|
|
js_random_bytes: function(buf, len) {
|
|
var bytes = new Uint8Array(len);
|
|
if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
|
crypto.getRandomValues(bytes);
|
|
} else {
|
|
// Node.js fallback
|
|
var nodeCrypto = require('crypto');
|
|
var nodeBytes = nodeCrypto.randomBytes(len);
|
|
bytes.set(nodeBytes);
|
|
}
|
|
HEAPU8.set(bytes, buf);
|
|
}
|
|
});
|