How to use the any-base function in any-base

To help you get started, we’ve selected a few any-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oliver-moran / jimp / packages / core / src / index.js View on Github external
}

    if (typeof base !== 'number') {
      return throwError.call(this, 'base must be a number', cb);
    }

    if (base < 2 || base > 64) {
      return throwError.call(
        this,
        'base must be a number between 2 and 64',
        cb
      );
    }

    let hash = this.pHash();
    hash = anyBase(anyBase.BIN, alphabet.slice(0, base))(hash);

    while (hash.length < maxHashLength[base]) {
      hash = '0' + hash; // pad out with leading zeros
    }

    if (isNodePattern(cb)) {
      cb.call(this, null, hash);
    }

    return hash;
  }
github ticky / markdown-component-loader / src / lowercase-hash.js View on Github external
export default (content) => (
  anyBase(anyBase.HEX, 'abcdefghijklmnopqrstuvwxyz')(
    new SHA256()
      .update(content, 'utf-8')
      .digest('hex')
  )
);

any-base

Converter from any base to other any base

MIT
Latest version published 7 years ago

Package Health Score

62 / 100
Full package analysis