mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Improve conversion between typed arrays
This commit is contained in:
@@ -35,7 +35,12 @@ export type EncryptedAttachment = {
|
||||
|
||||
// Generate a number between zero and 16383
|
||||
export function generateRegistrationId(): number {
|
||||
const id = new Uint16Array(getRandomBytes(2))[0];
|
||||
const bytes = getRandomBytes(2);
|
||||
const id = new Uint16Array(
|
||||
bytes.buffer,
|
||||
bytes.byteOffset,
|
||||
bytes.byteLength / 2
|
||||
)[0];
|
||||
|
||||
// eslint-disable-next-line no-bitwise
|
||||
return id & 0x3fff;
|
||||
|
||||
Reference in New Issue
Block a user