packages/otplib-utils/padSecret.js
function padSecret(secretBuffer, size, encoding) {
  const secret = secretBuffer.toString(encoding);
  const len = secret.length;

  if (size && len < size) {
    const newSecret = new Array(size - len + 1).join(
      secretBuffer.toString('hex')
    );
    return Buffer.from(newSecret, 'hex').slice(0, size);
  }

  return secretBuffer;
}
function padSecret(secretBuffer, size, encoding) {
  const secret = secretBuffer.toString(encoding);
  const len = secret.length;

  if (size && len < size) {
    const newSecret = new Array(size - len + 1).join(
      secretBuffer.toString('hex')
    );
    return Buffer.from(newSecret, 'hex').slice(0, size);
  }

  return secretBuffer;
}
function padSecret ( secretBuffer , size , encoding ) { const secret = secretBuffer . toString ( encoding ) ; const len = secret . length ; if ( size && len < size ) { const newSecret = new Array ( size - len + 1 ) . join ( secretBuffer . toString ( 'hex' ) ) ; return Buffer . from ( newSecret , 'hex' ) . slice ( 0 , size ) ; } return secretBuffer ; }
Padding of secret to a certain buffer size.

@module otplib-utils/padSecret
@param {Buffer} secretBuffer - a buffer representation of your secret.
@param {number} size - number of bytes your secret should be.
@param {string} encoding - the encoding of secret
@return {Buffer}
Padding of secret to a certain buffer size .