
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
string-crypto
Advanced tools
Small, simple, and secure no-dependency library to encrypt and decrypt strings using PBKDF2 for key derivation and AES (defaulted to 256-bit / SHA512)
Small, simple, and secure library to encrypt and decrypt strings using PBKDF2 for key derivation and AES (defaulted to 256-bit / SHA512).
This project is open to updates by its users, I ensure that PRs are relevant to the community. In other words, if you find a bug or want a new feature, please help us by becoming one of the contributors ✌️ ! See the contributing section.
crypto-js) not supporting this functionality directly. We switched to using crypto-js since Node's crypto is commonly breaking due to a missmatch with openssl versions.Please consider:
To encrypt a string, use the encrypt command with the required options:
npx string-crypto encrypt --string "Your String Here" --password "YourPassword"
Optional parameters:
--salt: Custom salt for encryption. If omitted, a random salt will be used.--iterations: Number of iterations (default is 1000).--keySize: Key size in bits (default is 256).To decrypt a string, use the decrypt command with the required options:
npx string-crypto decrypt --string "EncryptedStringHere" --password "YourPassword"
Optional parameters are the same as for encryption, except --digest is no longer available.
For more information or to see all available options, you can use the -h or --help flag:
npx string-crypto --help
npm i string-crypto
pnpm i string-crypto
yarn add string-crypto
import StringCrypto from 'string-crypto';
const stringToProtect = 'What is the largest (rational) number n such that there are positive integers p, q, r such that 1 - 1/p - 1/q - 1/r = 1/n?';
const password = 'Oh-no,not-again';
const sc = new StringCrypto();
let encryptedString = sc.encryptString(stringToProtect, password);
console.log('Encrypted String:', encryptedString);
console.log('Decrypted String:', sc.decryptString(encryptedString, password));
const options = {
salt: '2f0ijf2039j23r09j2fg45o9ng98um4o',
iterations: 1000,
keySize: 256, // Specify key size in bits
};
const sc = new StringCrypto(options);
I chose Rollup to handle the transpiling, compression, and any other transformations needed to get your Typescript code running as quickly and performant as possible.
This repo uses runkit.js to validate code sanity. Why? Because www.npmjs.com
uses Runkit to allow potential users to play with your module, live on
their browser, which is one of the best ways to convince someone to use your modules in their code.
Runkit will look for the runkit.js by default and display that as the initial playground for the
user, so by making it the default validation method during development, this encourages proper
communication with the users of your code.
Development
yarn dev
Uses concurrently to run Rollup in watch mode (which means it will transpile to dist when you
save changes to your code), as well as Nodemon to listen for changes in the dist directory and
re-run the runkit.js as you modify your source! This includes running node with the --inspect
flag so you can inspect your code using Google Chrome Dev Tools
(by opening chrome://inspect in your browser), you're welcome ;)
Build
yarn build
This command will build the dist/index.js, uglified and tree-shaken so it loads/runs faster.
It also generates a source map and a dist/index.d.ts type file for Typescript importing convenience.
Yes, thank you! This plugin is community-driven, most of its features are from different authors.
Please update the docs and tests and add your name to the package.json file.
Thanks goes to these wonderful people (emoji key):
Jean Lescure 🚧 💻 📓 ⚠️ 💡 📖 | Diana Lescure 📖 👀 🎨 |
FAQs
Small, simple, and secure no-dependency library to encrypt and decrypt strings using PBKDF2 for key derivation and AES (defaulted to 256-bit / SHA512)
The npm package string-crypto receives a total of 871 weekly downloads. As such, string-crypto popularity was classified as not popular.
We found that string-crypto 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.