Skip to main content

Cryptographic utilities for Musicfox Python applications.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mfcrypt-0.0.5a0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

mfcrypt-0.0.5a0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file mfcrypt-0.0.5a0.tar.gz.

File metadata

  • Download URL: mfcrypt-0.0.5a0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5

File hashes

Hashes for mfcrypt-0.0.5a0.tar.gz
Algorithm Hash digest
SHA256 46b688a961b81a24af13a8d1e8aad8cb90ded070af425c815efe620596ad2a23
MD5 4e51e32b04d5d32645d667c7a03d34b8
BLAKE2b-256 9d217c4dcafd707465310ee0eb8f77772b4bf07775fb5566725a9f793adb0f46

See more details on using hashes here.

File details

Details for the file mfcrypt-0.0.5a0-py3-none-any.whl.

File metadata

  • Download URL: mfcrypt-0.0.5a0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5

File hashes

Hashes for mfcrypt-0.0.5a0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbde9eafe50cf825f26469c85648bcef67202788c4659ae5b1645b5388bff7f9
MD5 f0069d222d5ea5ff33143a3e35d7b0c7
BLAKE2b-256 56bbd599890122d861777ff1f5b424f5805a9b756bb7a93e6394082cc2ad7921

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page