npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@musicfox/mfcrypt

v0.0.7

Published

Cryptographic utility functionality for Musicfox JavaScript applications, interoptable with Python Flask services.

Downloads

11

Readme

mfcrypt

AES encryption and decryption utilities for Musicfox JavaScript + Python applications and services. Plain Jane CBC encryption with HMAC (using sha256) payload authentication for both languages.

mfcrypt aims to offer the same API regardless of using JavaScript or Python. Save your data at rest in a database and access it from either language, as long as you know the key.

Motivation

The JavaScript and Python mfcrypt utilities are particularly simple/straightforward implementations of multi-layerd encryption within Musicfox software. In particular, it is important to be able to doubly encrypt data during application data SSL transport, at-rest under major-3rd party encryption (Google), and to separate concerns/implementations via completely different systems.

Combined with access restrictions underneath fortified enterprise authorization schemes, users' data are separated, encrypted, and always inaccessible by default. Multiple layers of service authorization and identification are required prior to any data utilized in plaintext.

Installation

It's easy to install the JavaScript and Python libraries. They're small and offered on npm and pypi.

JavaScript

Install via npm or yarn, e.g.

npm i --save-dev @musicfox/mfcrypt.

⚠️ Remove --save-dev if you're unsure!

Python

Install via pypi.

  • with Pip: pip install --upgrade mfcrypt
  • with Pipenv: pipenv install mfcrypt
  • with Poetry: poetry install mfcrypt

⚠️ Use --dev if this is an upstream dependency of your lib/app, rather than your dev environment.

Quick start JavaScript

For detailed usage examine the code in examples/javascript/ within the repo and the test suitefound in src/test/.

But the gist (we'll generate a simple bytes PDKDF2 key using the library):

// myEncryptionScript.js
import { createBytesKey, encrypt } from '@musicfox/mfcrypt';

const mySecretPassphrase = 'really I should encrypt this too, and generate it randomly. DO NOT use words like this. Tha NSA will break me.';
const salt = 'randomly generated salt';

const encStringData = await encrypt('TOP SECRET STRING DATA', mySecretPassphrase, salt);
const decStringData = await decrypt(encStringData, mySecretPassphrase, salt, 'string'); // give it a type hint at the end, you'll be happy you did ;-)

Quick start Python

For detailed usage examine the code in examples/python, which contains a Python Flask application you can test out. In addition, you can always examine usage via the test suite found in the test directory.

import mfcrypt

my_secret_passphrase = 'really I should encrypt this too, and generate it randomly. DO NOT use words like this. Tha NSA will break me.'
salt = 'randomly generated salt' 
enc_string_data = encrypt('TOP SECRET STRING DATA', my_secret_passphrase, salt)
dec_string_data = decrypt(enc_string_data, my_secret_passphrase, salt, type_hint='string')

Over-the-wire

This particular implementation is meant to work with Python HTTP webservices. As such, you should be able to use your code above to send encrypted data which may be decrypted via a Python service.

Support

File an issue or ask a question via Github.