Gathering detailed insights and metrics for crypto-js
Gathering detailed insights and metrics for crypto-js
Gathering detailed insights and metrics for crypto-js
Gathering detailed insights and metrics for crypto-js
JavaScript library of crypto standards.
npm install crypto-js
Typescript
Module System
Node Version
NPM Version
100
Supply Chain
100
Quality
75.9
Maintenance
100
Vulnerability
100
License
JavaScript (93.77%)
HTML (6.23%)
Built with Next.js • Fully responsive • SEO optimized • Open source ready
Total Downloads
1,533,716,876
Last Day
448,813
Last Week
9,129,991
Last Month
39,091,876
Last Year
411,087,679
NOASSERTION License
16,291 Stars
184 Commits
2,499 Forks
254 Watchers
5 Branches
24 Contributors
Updated on Sep 03, 2025
Latest Version
4.2.0
Package Id
crypto-js@4.2.0
Unpacked Size
475.53 kB
Size
85.24 kB
File Count
56
NPM Version
10.2.1
Node Version
18.18.0
Published on
Oct 24, 2023
Cumulative downloads
Total Downloads
Last Day
0.8%
448,813
Compared to previous day
Last Week
-0.7%
9,129,991
Compared to previous week
Last Month
-1.6%
39,091,876
Compared to previous month
Last Year
27%
411,087,679
Compared to previous year
JavaScript library of crypto standards.
Active development of CryptoJS has been discontinued. This library is no longer maintained.
Nowadays, NodeJS and modern browsers have a native Crypto
module. The latest version of CryptoJS already uses the native Crypto module for random number generation, since Math.random()
is not crypto-safe. Further development of CryptoJS would result in it only being a wrapper of native Crypto. Therefore, development and maintenance has been discontinued, it is time to go for the native crypto
module.
Requirements:
1npm install crypto-js
ES6 import for typical API call signing use case:
1import sha256 from 'crypto-js/sha256'; 2import hmacSHA512 from 'crypto-js/hmac-sha512'; 3import Base64 from 'crypto-js/enc-base64'; 4 5const message, nonce, path, privateKey; // ... 6const hashDigest = sha256(nonce + message); 7const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));
Modular include:
1var AES = require("crypto-js/aes"); 2var SHA256 = require("crypto-js/sha256"); 3... 4console.log(SHA256("Message"));
Including all libraries, for access to extra methods:
1var CryptoJS = require("crypto-js"); 2console.log(CryptoJS.HmacSHA1("Message", "Key"));
Requirements:
1bower install crypto-js
Modular include:
1require.config({ 2 packages: [ 3 { 4 name: 'crypto-js', 5 location: 'path-to/bower_components/crypto-js', 6 main: 'index' 7 } 8 ] 9}); 10 11require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) { 12 console.log(SHA256("Message")); 13});
Including all libraries, for access to extra methods:
1// Above-mentioned will work or use this simple form 2require.config({ 3 paths: { 4 'crypto-js': 'path-to/bower_components/crypto-js/crypto-js' 5 } 6}); 7 8require(["crypto-js"], function (CryptoJS) { 9 console.log(CryptoJS.HmacSHA1("Message", "Key")); 10});
1<script type="text/javascript" src="path-to/bower_components/crypto-js/crypto-js.js"></script> 2<script type="text/javascript"> 3 var encrypted = CryptoJS.AES(...); 4 var encrypted = CryptoJS.SHA256(...); 5</script>
See: https://cryptojs.gitbook.io/docs/
1var CryptoJS = require("crypto-js"); 2 3// Encrypt 4var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString(); 5 6// Decrypt 7var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123'); 8var originalText = bytes.toString(CryptoJS.enc.Utf8); 9 10console.log(originalText); // 'my message'
1var CryptoJS = require("crypto-js"); 2 3var data = [{id: 1}, {id: 2}] 4 5// Encrypt 6var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString(); 7 8// Decrypt 9var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123'); 10var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8)); 11 12console.log(decryptedData); // [{id: 1}, {id: 2}]
crypto-js/core
crypto-js/x64-core
crypto-js/lib-typedarrays
crypto-js/md5
crypto-js/sha1
crypto-js/sha256
crypto-js/sha224
crypto-js/sha512
crypto-js/sha384
crypto-js/sha3
crypto-js/ripemd160
crypto-js/hmac-md5
crypto-js/hmac-sha1
crypto-js/hmac-sha256
crypto-js/hmac-sha224
crypto-js/hmac-sha512
crypto-js/hmac-sha384
crypto-js/hmac-sha3
crypto-js/hmac-ripemd160
crypto-js/pbkdf2
crypto-js/aes
crypto-js/tripledes
crypto-js/rc4
crypto-js/rabbit
crypto-js/rabbit-legacy
crypto-js/evpkdf
crypto-js/format-openssl
crypto-js/format-hex
crypto-js/enc-latin1
crypto-js/enc-utf8
crypto-js/enc-hex
crypto-js/enc-utf16
crypto-js/enc-base64
crypto-js/mode-cfb
crypto-js/mode-ctr
crypto-js/mode-ctr-gladman
crypto-js/mode-ofb
crypto-js/mode-ecb
crypto-js/pad-pkcs7
crypto-js/pad-ansix923
crypto-js/pad-iso10126
crypto-js/pad-iso97971
crypto-js/pad-zeropadding
crypto-js/pad-nopadding
Change default hash algorithm and iteration's for PBKDF2 to prevent weak security by using the default configuration.
Custom KDF Hasher
Blowfish support
Fix module order in bundled release.
Include the browser field in the released package.json.
Added url safe variant of base64 encoding. 357
Avoid webpack to add crypto-browser package. 364
This is an update including breaking changes for some environments.
In this version Math.random()
has been replaced by the random methods of the native crypto module.
For this reason CryptoJS might not run in some JavaScript environments without native crypto module. Such as IE 10 or before or React Native.
Rollback, 3.3.0
is the same as 3.1.9-1
.
The move of using native secure crypto module will be shifted to a new 4.x.x
version. As it is a breaking change the impact is too big for a minor release.
The usage of the native crypto module has been fixed. The import and access of the native crypto module has been improved.
In this version Math.random()
has been replaced by the random methods of the native crypto module.
For this reason CryptoJS might does not run in some JavaScript environments without native crypto module. Such as IE 10 or before.
If it's absolute required to run CryptoJS in such an environment, stay with 3.1.x
version. Encrypting and decrypting stays compatible. But keep in mind 3.1.x
versions still use Math.random()
which is cryptographically not secure, as it's not random enough.
This version came along with CRITICAL
BUG
.
DO NOT USE THIS VERSION! Please, go for a newer version!
The 3.1.x
are based on the original CryptoJS, wrapped in CommonJS modules.
No vulnerabilities found.