JavaScript implementations of standard and secure cryptographic algorithms
CryptoJS is a growing collection of standard and secure cryptographic algorithms implemented in JavaScript using best practices and patterns. They are fast, and they have a consistent and simple interface.

Code Block


The Hashing Algorithms
1. MD5
MD5 is a widely used hash function. It's been used in a variety of security applications and is also commonly used to check the integrity of files. Though, MD5 is not collision resistant, and it isn't suitable for applications like SSL certificates or digital signatures that rely on this property.

var hash = CryptoJS.MD5("Message");
  1. SHA-1
    The SHA hash functions were designed by the National Security Agency (NSA). SHA-1 is the most established of the existing SHA hash functions, and it's used in a variety of security applications and protocols. Though, SHA-1's collision resistance has been weakening as new attacks are discovered or improved.
var hash = CryptoJS.SHA1("Message");

to be continue ...


import CryptoJS from 'crypto-js'
import readline from 'readline'

var key1 = 'DE0868F6BEA8AD914229595C2BD4ABD1';
var vi1 = '83450100378107005B01000000000000';
var payload1 = '...';
var key2 = '...';
var vi2 = '...';
var payload2 = '...';
var key3 = '...';
var vi3 = '...';
var payload3 = '...';
var true_res1 = '...';
var true_res2 = '...';
var true_res3 = '...';

function cryptojs(text, key, vi) {
  const out = CryptoJS.AES.encrypt(
    CryptoJS.enc.Latin1.parse(Buffer.from(text, 'hex').toString('binary')),
      iv: CryptoJS.enc.Hex.parse(vi),
      mode:  CryptoJS.mode.CTR,
      padding: CryptoJS.pad.NoPadding,
  return out.ciphertext.toString();

console.log(cryptojs(payload1, key1, vi1) == true_res1);
console.log(cryptojs(payload2, key2, vi2) == true_res2);
console.log(cryptojs(payload3, key3, vi3) == true_res3);