crypto: set length when converting uint8array to buffer

This commit is contained in:
Abdullah Atta
2023-06-24 16:30:04 +05:00
committed by Abdullah Atta
parent 5774daf3a9
commit e6b9219d75

View File

@@ -412,7 +412,7 @@ function toBuffer<TInput extends ToBufferInput>(
input: TInput
): ToBufferResult<TInput> {
if (input instanceof Uint8Array) {
return Buffer.from(input.buffer);
return Buffer.from(input.buffer, 0, input.byteLength);
} else if (typeof input === "undefined" || input === null) {
return undefined as ToBufferResult<TInput>;
} else {