crypto-js
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Crypto-js is an extensive JavaScript library of cryptographic standards. This npm package can be implemented to perform a wide array of crypto standards including but not limited to MD5, SHA-1, SHA-256, HMAC-SHA512, AES Encryption, and methods within the OpenSSL library. It simplifies the process of applying intricate cryptographic solutions within your application development process.
Using crypto-js is straightforward, requiring a node.js environment and npm for the installation. After installing the package using npm install crypto-js
, the methods can be imported directly using ES6 methods or using require if you want different modules or all the libraries. For generating hashed data, the desired method can be called with the correct arguments, for example:
import sha256 from 'crypto-js/sha256';
console.log(sha256("Your Message"));
When it comes to encrypting and decrypting plaintext or objects, it's as simple as using the encrypt and decrypt methods from the AES module:
var CryptoJS = require("crypto-js");
// Encrypt
var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();
// Decrypt
var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
var originalText = bytes.toString(CryptoJS.enc.Utf8);
console.log(originalText); // 'my message'
The official documents of crypto-js, which include additional usage examples and API definitions, can be accessed at https://cryptojs.gitbook.io/docs/. You can find a comprehensive list of modules, detailed usage explanations, and learn about new features or fixes in the latest versions.