Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Convert SVG to base64 anywhere
If you, like me, are using lots of SVGs when developing, you might have come to a point where you need your SVG used as background image or embedded in your javascript file. The only way to do this is to convert your SVG file to a base64 string and then use it where needed. This package does exactly this - it converts SVGs to base64.
This package works in a browser and in a Node environment. Please read along to understand how.
npm i svg64
or
yarn add svg64
or
just download this repository and use the files located in dist
folder
or unclude it from unpkg.com
<script src="https://unpkg.com/svg64"></script>
import svg64 from 'svg64'; // or use window.svg64.default
// This is your SVG DOM element
const svg = document.getElementById('svg');
// This is your DOM element that needs SVG background image
const demo = document.getElementById('demo');
// This is your SVG in base64 representation
const base64fromSVG = svg64(svg);
// Add the base64 image as a background to your element
demo.style.backgroundImage = `url(${base64fromSVG})`;
// Require svg64
const svg64 = require('svg64');
// Import `readFileSync` from the file system module
const { readFileSync } = require('fs');
// Read your SVG file's contents
const svg = readFileSync('./file.svg', 'utf-8');
// This is your SVG in base64 representation
const base64fromSVG = svg64(svg);
There is a simple demo illustrating how to use the SVG64 module in a browser.
Check it out here
There is a simple demo illustrating how to use the SVG64 module in NodeJS.
Check it out here
MIT
FAQs
Convert SVG to base64 anywhere
We found that svg64 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.