How to use the crc/crc32.default function in crc

To help you get started, we’ve selected a few crc 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 MahjongPantheon / pantheon / Tyr / src / app / primitives / appstate / index.ts View on Github external
init() {
    let loc = window.location.pathname.replace(/^\//, '');
    if (loc.length > 0) {
      let [pin, crc] = loc.split('_');
      if (crc32(pin).toString(16).toLowerCase() === crc.toLowerCase()) {
        window.history.pushState({}, '', '/'); // to remove pathname
        this.storage.delete(['authToken']);
        this._currentScreen = 'login';
        this.loginWithPin(pin)
          .then(() => {
            this.init(); // Should not enter endless loop because path should be empty here.
          })
          .catch((e) => {
            console.error(e);
            this.metrika.track(MetrikaService.LOAD_ERROR, {
              type: 'state-init-login',
              request: 'confirmRegistration',
              message: e.toString()
            });
          });
        return;
github MahjongPantheon / pantheon / Tyr / src / app / services / qr.ts View on Github external
canvas.drawImage(this._video, 0, 0, canvasElement.width, canvasElement.height);
        let imageData = canvas.getImageData(0, 0, canvasElement.width, canvasElement.height);
        let code = jsQR(imageData.data, imageData.width, imageData.height, {
          inversionAttempts: 'dontInvert',
        });

        if (code) {
          let pincode = '';
          let data = code.data.match(/^https?:\/\/(.*?)\/(\d+)_([\da-f]+)$/i);
          if (data) {
            if (data[1].split(':')[0] === 'localhost') { // local debug
              pincode = data[2];
            } else {
              if (
                data[1].split(':')[0] === location.host &&
                crc32(data[2]).toString(16).toLowerCase() === data[3].toLowerCase()
              ) {
                pincode = data[2];
              }
            }
          }

          if (pincode.length > 0) {
            this._stopVideo();
            this._video.pause();
            this._onPinReceived(pincode);
            return;
          }
        }
      }

      requestAnimationFrame(tick);

crc

Module for calculating Cyclic Redundancy Check (CRC) for Node.js and the browser.

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis