Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cryptojs2

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cryptojs2

cryptojs2 with import

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by133.33%
Maintainers
1
Weekly downloads
 
Created
Source

cryptojs2

JavaScript library of crypto standards.

Node.js (Install)

Requirements:

  • Node.js
npm install cryptojs2

Usage

Node.js

import sha256 from 'cryptojs2/sha256';
import hmacSHA256 from 'cryptojs2/hmac-sha256'; 
//or
import {SHA256 as sha256,HmacSHA256 as hmacSha256} from "cryptojs2";   

const message, nonce, path, privateKey; // ...
const hashDigest = sha256(nonce + message);
const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));

Client (browser)

Requirements:

Usage

Modular include:

Usage without RequireJS

<script type="module">
import sha256 from 'cryptojs2/sha256';
import hmacSHA256 from 'cryptojs2/hmac-sha256'; 
//or
import {SHA256 as sha256,HmacSHA256 as hmacSha256} from "cryptojs2";   

window.sha256 = sha256; //FOR USE ALL DOCUMENT
window.hmacSHA256 = hmacSHA256; //FOR USE ALL DOCUMENT
    var hashSHA256 = sha256("Message");
    var hashhmacSha256 =hmacSha256("stringToSign", "signingKey");
</script>

AES Encryption

Plain text encryption
import aes from 'cryptojs2/AES';
import hmacSHA256 from 'cryptojs2/hmac-sha256'; 

// Encrypt
var ciphertext = aes.encrypt('message', 'secret key').toString();

// Decrypt
var bytes  = aes.decrypt(ciphertext, 'secret key');
var originalText = bytes.toString();

console.log(originalText); // 'message'
Object encryption
import aes from 'cryptojs2/AES';

var data = [{id: 1}, {id: 2}]

// Encrypt
var ciphertext = aes.encrypt(JSON.stringify(data), 'secret key 123').toString();

// Decrypt
var bytes  = aes.decrypt(ciphertext, 'secret key 123');
var decryptedData = JSON.parse(bytes.toString());

console.log(decryptedData); // [{id: 1}, {id: 2}]

List of modules

  • cryptojs2/md5
  • cryptojs2/sha1
  • cryptojs2/sha256
  • cryptojs2/sha224
  • cryptojs2/sha512
  • cryptojs2/sha384
  • cryptojs2/sha3
  • cryptojs2/ripemd160

  • cryptojs2/hmac-md5
  • cryptojs2/hmac-sha1
  • cryptojs2/hmac-sha256
  • cryptojs2/hmac-sha224
  • cryptojs2/hmac-sha512
  • cryptojs2/hmac-sha384
  • cryptojs2/hmac-sha3
  • cryptojs2/hmac-ripemd160

  • cryptojs2/pbkdf2

  • cryptojs2/aes
  • cryptojs2/tripledes
  • cryptojs2/rc4
  • cryptojs2/rabbit
  • cryptojs2/rabbit-legacy

License

MIT license; see LICENSE.

Keywords

FAQs

Package last updated on 26 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc