diff --git a/src/Utils/generics.ts b/src/Utils/generics.ts index 9da7a21b..13facf88 100644 --- a/src/Utils/generics.ts +++ b/src/Utils/generics.ts @@ -70,14 +70,9 @@ export const getKeyAuthor = (key: proto.IMessageKey | undefined | null, meId = ' export const writeRandomPadMax16 = (msg: Uint8Array) => { const pad = randomBytes(1) + const padLength = (pad[0]! & 0x0f) + 1 - if (pad[0]) { - pad[0] &= 0xf - } else { - pad[0] = 0xf - } - - return Buffer.concat([msg, Buffer.alloc(pad[0], pad[0])]) + return Buffer.concat([msg, Buffer.alloc(padLength, padLength)]) } export const unpadRandomMax16 = (e: Uint8Array | Buffer) => {