From 8183ee2028ef3095ae3724b0da968bcc5a057ffc Mon Sep 17 00:00:00 2001 From: caru-ini Date: Tue, 2 Jul 2024 23:59:12 +0900 Subject: [PATCH] fix: add zero padding for odd-length string --- server/domain/user/service/srp/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/domain/user/service/srp/util.ts b/server/domain/user/service/srp/util.ts index fec121f..078f691 100644 --- a/server/domain/user/service/srp/util.ts +++ b/server/domain/user/service/srp/util.ts @@ -30,7 +30,7 @@ export const padBufferToHex = (buffer: Buffer): string => { export const toBuffer = (bigInt: BigInteger): Buffer => { const str = bigInt.toString(16); - return Buffer.from(str, 'hex'); + return Buffer.from(str.padStart(str.length + (str.length % 2), '0'), 'hex'); }; export const toBufferWithLength = (bigInt: BigInteger, length: number): Buffer => {