JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q49759F
  • License ISC

Migrated mcrypt.js from F. Doering jsmcrypt Version 0.1 (https://code.google.com/archive/p/js-mcrypt/)

Package Exports

  • fdoering-mcrypt

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fdoering-mcrypt) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fdoering-mcrypt

NodeJS module - migrated mcrypt.js from F. Doering jsmcrypt Version 0.1 (https://code.google.com/archive/p/js-mcrypt/).

jsmcrypt version 0.1 - Copyright 2012 F. Doering

Install with npm

npm install fdoering-mcrypt

NodeJS Encrypt Example

// Require
var mcrypt = require("fdoering-mcrypt");

// Pseudo key **DO NOT USE THIS**
var key = "12345678901234567890123456789012";
// Pseudo initialization vector (iv)
var iv = "abcdefghijklmnopqrstuv1234567890";

// Plaintext
var message = "Hello there!";

// Encrypt
var encrypted_binary = mcrypt.Encrypt(message, iv, key, "rijndael-256", "cbc");

// Convert to Base64 for transporting using Node.js native Buffer class.
var encrypted_base64 = Buffer.from(encrypted_binary, "binary").toString("base64");

NodeJS Decrypt Example

// Convert Base64 back to Binary
var encrypted_binary = Buffer.from(encrypted_base64, "base64").toString("binary");

// Decrypt
var plaintext = mcrypt.Decrypt(encrypted_binary, iv, key, "rijndael-256", "cbc");

// Remove padding
plaintext = plaintext.replace(/\0/g,'');

// Prints "Hello there!"
console.log(plaintext);