🔒
Auth5M+/wkMIT

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
npm install crypto-js
yarn
yarn add crypto-js
pnpm
pnpm add crypto-js

Import

ESM
import CryptoJS from 'crypto-js';

Quick Example

usage
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

Packagecrypto-js
CategoryAuth
Weekly Downloads5M+
LicenseMIT
Installnpm install crypto-js

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.