Skip to content

Commit

Permalink
fix: add zero padding for odd-length string
Browse files Browse the repository at this point in the history
  • Loading branch information
caru-ini committed Jul 2, 2024
1 parent f051d79 commit 8183ee2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion server/domain/user/service/srp/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 8183ee2

Please sign in to comment.