JavaScript library of crypto standards.
This package is a fork of crypto-js, with added support for SEED encryption and Type Definitions, and has been republished as a separate library.
- Fixed Typo in
AnsiX923Padding Module- Resolved an issue where a typo in the
AnsiX923padding module prevented it from functioning correctly in the originalcrypto-js.
- Resolved an issue where a typo in the
- Added SEED Algorithm Module
- Integrated the
SEEDencryption algorithm, which is not included in the originalcrypto-js, from an external package.
- Integrated the
- Included Type Definitions
- Eliminates the need to install
@types/crypto-jsseparately, as Type Definitions are now bundled within this package.
- Eliminates the need to install
🔹 Why This Package?
The native Crypto module in Node.js does not support SEED encryption, making it necessary to extend crypto-js to provide this functionality. This package allows developers to use SEED encryption seamlessly in their projects. 🚀
Requirements:
- Node.js
$ npm install @leo-util/crypto-js
ES6 import for typical API call signing use case:
import sha256 from '@leo-util/crypto-js/sha256';
import hmacSHA512 from '@leo-util/crypto-js/hmac-sha512';
import Base64 from '@leo-util/crypto-js/enc-base64';
const message, nonce, path, privateKey; // ...
const hashDigest = sha256(nonce + message);
const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));Modular include:
const AES = require("@leo-util/crypto-js/aes");
const SHA256 = require("@leo-util/crypto-js/sha256");
...
console.log(SHA256("Message"));Including all libraries, for access to extra methods:
const CryptoJS = require("@leo-util/crypto-js");
console.log(CryptoJS.HmacSHA1("Message", "Key"));See: https://cryptojs.gitbook.io/docs/
const CryptoJS = require("@leo-util/crypto-js");
// Encrypt
const ciphertext = CryptoJS.SEED.encrypt('my message', 'secret key 123', {
mode: CryptoJS.mode.ECB, // CryptoJS.mode.CBC, ...
padding: CryptoJS.pad.ZeroPadding, // CryptoJS.pad.Pkcs7, ...
// iv...
});
// Decrypt
const bytes = CryptoJS.SEED.decrypt(ciphertext, 'secret key 123', {
mode: CryptoJS.mode.ECB
padding: CryptoJS.pad.ZeroPadding
});
const originalText = bytes.toString(CryptoJS.enc.Utf8);
console.log(originalText); // 'my message'const CryptoJS = require("@leo-util/crypto-js");
// Encrypt
const ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();
// Decrypt
const bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
const originalText = bytes.toString(CryptoJS.enc.Utf8);
console.log(originalText); // 'my message'const CryptoJS = require("@leo-util/crypto-js");
const data = [{id: 1}, {id: 2}]
// Encrypt
const ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString();
// Decrypt
const bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
const decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
console.log(decryptedData); // [{id: 1}, {id: 2}]@leo-util/crypto-js/core@leo-util/crypto-js/x64-core@leo-util/crypto-js/lib-typedarrays
@leo-util/crypto-js/md5@leo-util/crypto-js/sha1@leo-util/crypto-js/sha256@leo-util/crypto-js/sha224@leo-util/crypto-js/sha512@leo-util/crypto-js/sha384@leo-util/crypto-js/sha3@leo-util/crypto-js/ripemd160
@leo-util/crypto-js/hmac-md5@leo-util/crypto-js/hmac-sha1@leo-util/crypto-js/hmac-sha256@leo-util/crypto-js/hmac-sha224@leo-util/crypto-js/hmac-sha512@leo-util/crypto-js/hmac-sha384@leo-util/crypto-js/hmac-sha3@leo-util/crypto-js/hmac-ripemd160
@leo-util/crypto-js/pbkdf2
@leo-util/crypto-js/aes@leo-util/crypto-js/seed@leo-util/crypto-js/tripledes@leo-util/crypto-js/rc4@leo-util/crypto-js/rabbit@leo-util/crypto-js/rabbit-legacy@leo-util/crypto-js/evpkdf
@leo-util/crypto-js/format-openssl@leo-util/crypto-js/format-hex
@leo-util/crypto-js/enc-latin1@leo-util/crypto-js/enc-utf8@leo-util/crypto-js/enc-hex@leo-util/crypto-js/enc-utf16@leo-util/crypto-js/enc-base64
@leo-util/crypto-js/mode-cfb@leo-util/crypto-js/mode-ctr@leo-util/crypto-js/mode-ctr-gladman@leo-util/crypto-js/mode-ofb@leo-util/crypto-js/mode-ecb
@leo-util/crypto-js/pad-pkcs7@leo-util/crypto-js/pad-ansix923@leo-util/crypto-js/pad-iso10126@leo-util/crypto-js/pad-iso97971@leo-util/crypto-js/pad-zeropadding@leo-util/crypto-js/pad-nopadding