
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@shreyaadhikari/qr-code-generator
Advanced tools
QR Code Generator is a simple Node.js package for generating QR codes and saving them as image files. Ideal for adding QR code functionality to your Node.js applications effortlessly.
You can install this package using npm:
npm install @shreyaadhikari/qr-code-generator
Here’s a quick guide on how to use the QR Code Generator in your Node.js project.
const generateQRCode = require('@shreyaadhikari/qr-code-generator');
const text = 'Hello World';
const outputPath = 'qrcode.png';
generateQRCode(text, outputPath, (err, message) => {
if (err) {
console.error('Error generating QR code:', err);
} else {
console.log(message); // Output: 'QR Code saved to qrcode.png'
}
});
Here is a complete example using a file named test.js:
const generateQRCode = require('@shreyaadhikari/qr-code-generator');
const text = 'Hello World';
const outputPath = 'qrcode.png';
generateQRCode(text, outputPath, (err, message) => {
if (err) {
console.error('Error generating QR code:', err);
} else {
console.log(message); // Output: 'QR Code saved to qrcode.png'
}
});
This package is designed for use with Node.js. See the Usage section for examples.
To use this package in a browser, include the script tag as follows:
<script src="https://cdn.jsdelivr.net/npm/@yourusername/qr-code-generator"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QR Code Generator</title>
</head>
<body>
<input type="text" id="textInput" placeholder="Enter text for QR Code">
<button id="generateButton">Generate QR Code</button>
<img id="qrCodeImage" alt="QR Code">
<script src="https://cdn.jsdelivr.net/npm/@shreyaadhikari/qr-code-generator"></script>
<script>
document.getElementById('generateButton').addEventListener('click', () => {
const text = document.getElementById('textInput').value;
const outputPath = 'data:image/png;base64,'; // QR code will be displayed as a base64-encoded PNG
generateQRCode(text, outputPath, (err, imageSrc) => {
if (err) {
console.error('Error generating QR code:', err);
} else {
document.getElementById('qrCodeImage').src = imageSrc;
}
});
});
</script>
</body>
</html>
This package requires the following dependencies:
Q: What if I encounter an error generating the QR code?
A: Make sure the text input is a valid string and check the file path permissions.
Contributions are welcome! If you want to improve this package, follow these steps:
This package is licensed under the ISC License. See the LICENSE file for details.
For questions or suggestions, feel free to open an issue on the GitHub repository or contact me at shreya.adh09@gmail.com
.
FAQs
A utility package to generate QR codes
The npm package @shreyaadhikari/qr-code-generator receives a total of 1 weekly downloads. As such, @shreyaadhikari/qr-code-generator popularity was classified as not popular.
We found that @shreyaadhikari/qr-code-generator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.