crypto-js
CryptoJS is a JavaScript library of cryptographic standards providing implementations of popular hashing algorithms, ciphers, and encoding utilities that work i…
Installation
npm install crypto-js
yarn add crypto-js
pnpm add crypto-js
Import
import CryptoJS from 'crypto-js';
Quick Example
import CryptoJS from 'crypto-js';
// Hashing
const hash = CryptoJS.SHA256('hello').toString();
// Encryption
const encrypted = CryptoJS.AES.encrypt('message', 'secret-key').toString();
const decrypted = CryptoJS.AES.decrypt(encrypted, 'secret-key')
.toString(CryptoJS.enc.Utf8);About crypto-js
CryptoJS is a JavaScript library of cryptographic standards providing implementations of popular hashing algorithms, ciphers, and encoding utilities that work in both browser and Node.js environments. The library includes hash functions (MD5, SHA-1, SHA-256, SHA-512, SHA-3, RIPEMD-160), keyed-hash message authentication codes (HMAC with any hash function), symmetric encryption algorithms (AES, DES, Triple DES, Rabbit, RC4), and encoding utilities (Base64, Hex, UTF-8, Latin1). CryptoJS is particularly useful in browser environments where the Web Crypto API may not support all needed algorithms, or when synchronous cryptographic operations are required. The AES implementation supports CBC, CFB, CTR, OFB, and ECB modes with PKCS7 padding. For common use cases, CryptoJS provides simple string-based encryption: CryptoJS.AES.encrypt('message', 'secret').toString() and CryptoJS.AES.decrypt(ciphertext, 'secret').toString(CryptoJS.enc.Utf8). While Node.js's built-in crypto module and the Web Crypto API are recommended for security-critical applications, CryptoJS remains popular for its simple API, browser compatibility, and convenience for non-security-critical cryptographic operations like checksums and basic encryption.
Quick Facts
| Package | crypto-js |
| Category | Auth |
| Weekly Downloads | 5M+ |
| License | MIT |
| Install | npm install crypto-js |
Related Packages
jose is a universal, standards-compliant JavaScript library implementing JSON Object Signing and Enc…
bcrypt is a library for hashing passwords using the bcrypt algorithm, which is specifically designed…
jsonwebtoken is the most widely used library for creating and verifying JSON Web Tokens (JWTs) in No…
uuid is the standard library for generating RFC 4122 compliant Universally Unique Identifiers (UUIDs…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.