How to use qr-image - 10 common examples

To help you get started, we’ve selected a few qr-image 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 brave / browser-laptop / app / sync.js View on Github external
ipcMain.on(messages.SAVE_INIT_DATA, (e, seed, newDeviceId) => {
    const isRestoring = seed && !newDeviceId
    if (!deviceId && newDeviceId) {
      deviceId = Array.from(newDeviceId)
    }
    if (!seed && newDeviceId) {
      appActions.saveSyncInitData(null, new Immutable.List(newDeviceId), null)
      return
    }
    try {
      let chunks = []
      qr.image(Buffer.from(seed).toString('hex')).on('data', (chunk) => {
        chunks.push(chunk)
      }).on('end', () => {
        let seedQr = 'data:image/png;base64,' + Buffer.concat(chunks).toString('base64')
        appActions.saveSyncInitData(new Immutable.List(seed),
          newDeviceId ? new Immutable.List(newDeviceId) : null, null, seedQr)
      })
    } catch (ex) {
      console.log('qr image error: ' + ex.toString())
      appActions.saveSyncInitData(new Immutable.List(seed),
        newDeviceId ? new Immutable.List(newDeviceId) : null)
    }
    if (isRestoring) {
      // we are restoring from a previous seed. wait for the seed to be saved
      // before reloading, or sync-client will override the seed.
      process.emit(RELOAD_MESSAGE)
    }
github brave / brave-core / components / brave_rewards / ui / utils.ts View on Github external
case 'ETH':
        url = `ethereum:${address}`
        break
      case 'BTC':
        url = `bitcoin:${address}`
        break
      case 'LTC':
        url = `litecoin:${address}`
        break
      default:
        return
    }

    try {
      let chunks: Uint8Array[] = []
      qr.image(url, { type: 'png' })
        .on('data', (chunk: Uint8Array) => {
          chunks.push(chunk)
        })
        .on('end', () => {
          const qrImage = 'data:image/png;base64,' + Buffer.concat(chunks).toString('base64')
          if (actions) {
            actions.onQRGenerated(type, qrImage)
          }
        })
    } catch (ex) {
      console.error('qr.imageSync (for url ' + url + ') error: ' + ex.toString())
    }
  }
github brave / browser-laptop / app / browser / api / ledger.js View on Github external
case 'ETH':
        url = `ethereum:${address}`
        break
      case 'BTC':
        url = `bitcoin:${address}`
        break
      case 'LTC':
        url = `litecoin:${address}`
        break
      default:
        return
    }

    try {
      let chunks = []
      qr.image(url, {type: 'png'})
        .on('data', (chunk) => {
          chunks.push(chunk)
        })
        .on('end', () => {
          const paymentIMG = 'data:image/png;base64,' + Buffer.concat(chunks).toString('base64')
          appActions.onLedgerQRGenerated(index, paymentIMG)
        })
    } catch (ex) {
      console.error('qr.imageSync (for url ' + url + ') error: ' + ex.toString())
    }
  })
github austintgriffith / paper-wallet / create.js View on Github external
var publicAddress = process.argv[2]
let PK = process.argv[3]
let URL = process.argv[4]

let pkLink
if(COMPRESS){
  function pkToUrl(pk) {
    return base64url(web3.utils.hexToBytes(pk))
  }
  let encoded = pkToUrl(PK)
  pkLink = URL+"/pk#"+encoded
}else{
  pkLink = URL+"/pk#"+PK.replace("0x","")
}
//console.log(pkLink)
var private = qr.image(pkLink, { type: 'png' });
private.pipe(require('fs').createWriteStream('private.png'));

var public = qr.image(URL+"/"+publicAddress, { type: 'svg' });
public.pipe(require('fs').createWriteStream('public.svg'));

console.log(publicAddress)

fs.readFile("template.html", 'utf8', (err,data) => {
  if (err) {
    return console.log(err);
  }
  var result = data.replace(/\*\*PUBLIC\*\*/g,publicAddress.substring(0,9)+"......"+publicAddress.substring(publicAddress.length-8));
  result = result.replace(/\*\*URL\*\*/g,URL);
  result = result.replace(/"\.\//g, "\"file://"+__dirname+"/");

  console.log(result)
github shivensinha4 / qr-fileshare / index.js View on Github external
function displayQrCode(address) {
  const qr_image = qr.imageSync(address, {parse_url: true, size: 1, margin: 3, ec_level: 'H'}),
      qr_svg = qr.image(address, { type: 'svg' });

  qr_svg.pipe(require('fs').createWriteStream('generated_qr.svg'));

  pngStringify(qr_image, (err, pngStr) => {
    if (err) throw err;
    console.log(pngStr);
  });
}
github Overtorment / Cashier-BTC / controllers / website.js View on Github external
router.get('/generate_qr/:text', function (req, res) {
  let filename
  let qrSvg
  filename = 'qr/' + crypto.createHash('sha1').update(decodeURIComponent(req.params.text)).digest('hex') + '.png'
  qrSvg = qr.image(decodeURIComponent(req.params.text), { type: 'png' })
  qrSvg.pipe(fs.createWriteStream(filename))
  qrSvg.on('end', function () {
    res.redirect(301, '/' + filename)
    res.end()
  })
  qrSvg.on('error', function () {
    res.send('QR file error')
    res.end()
  })
})
github HackGT / registration / server / common.ts View on Github external
let qrBuffer = await new Promise(resolve => {
		let qrStream = qr.image(`user:${user.uuid}`);
		let buffer: any[] = [];
		qrStream.on("data", chunk => {
			buffer.push(chunk);
		});
		qrStream.on("end", () => {
			resolve(Buffer.concat(buffer));
		});
	});
	let qrURI = `data:image/png;base64,${qrBuffer.toString("base64")}`;
github Srar / AlipayF2F / express-example / controllers / index.js View on Github external
router.get('/createQRCode', (req, res) => {
	var text = req.query.text || "";
	try {
		var img = qr.image(text,{size :10});
		res.writeHead(200, {'Content-Type': 'image/png'});
		img.pipe(res);
	} catch (e) {
		res.writeHead(414, {'Content-Type': 'text/html'});
		res.end('<h1>414 Request-URI Too Large</h1>');
	}
});
github node-weixin / node-weixin-express / lib / router / express / qrcode.js View on Github external
settings.get(id, 'urls', function(urls) {
      switch (req.params.type) {
        case 'jssdk':
          str = urls.jssdk.main;
          break;
        case 'oauth':
          str = urls.oauth.access;
          break;
        case 'pay':
          str = urls.pay.main;
          break;
      }
      var code = qr.image(str, {type: 'svg'});
      res.type('svg');
      code.pipe(res);
    });
  });
github doramart / DoraCMS / app / controller / page / home.js View on Github external
async createQRCode(ctx, app) {
        var text = ctx.request.query.text || "";
        if (text) {
            let img = qr.image(text, {
                size: 10
            });
            ctx.set('Content-Type', 'image/png');
            ctx.status = 200;
            ctx.body = img;
        } else {
            throw new Error(ctx.__('validate_error_params'));
        }
    }

qr-image

QR Code generator (png, svg, pdf, eps)

MIT
Latest version published 8 years ago

Package Health Score

50 / 100
Full package analysis

Popular qr-image functions