@thezelijah/majik-blob
v1.0.3
Published
Majik Blob is a lightweight TypeScript/JavaScript library for securely encrypting and decrypting files (Blobs). Ideal for obfuscating files before storing or transmitting, preserving file type and extension, and preventing unauthorized access.
Downloads
22
Maintainers
Readme
Majik Blob
Majik Blob is a lightweight JavaScript/TypeScript library for encrypting and decrypting files (Blobs) securely.
It’s ideal for scenarios where you want to store files in cloud storage or deliver files but prevent direct access or downloads without the correct key.
Live Demo
Click the image to try Majik Blob.
✨ Features
- 🔐 Encrypt any file type (images, audio, video, 3D models, documents, etc.)
- 📦 Returns a single encrypted Blob (
.mjkb) with metadata for integrity verification - 🧾 Preserves original MIME type & file extension
- 🧪 Tamper detection and password verification
- ⚡ Fully reversible with the correct key and RQX
- 💨 Optional compression to reduce file size before encryption
- 🌐 Browser-first, TypeScript-friendly
Full API Docs
📦 Installation
npm i @thezelijah/majik-blobUsage
Generate a Key
Encrypts the file and returns a .mjkb Blob. Majik Blob uses a password and an internal RQX key for encryption. Generate a key securely before encrypting:
import { MajikBlob } from "@thezelijah/majik-blob";
const { key, rqx } = MajikBlob.generateKey(32); // 32-character passwordEncrypting Files
Optionally compress files before encryption to reduce size:
import { MajikBlob } from "@thezelijah/majik-blob";
import { downloadBlob } from "@thezelijah/majik-blob/utils";
const file = new File(["Hello world"], "example.txt", { type: "text/plain" });
const majik = new MajikBlob(key, file);
const encryptedBlob = await majik.getEncryptedBlob(rqx, true); // true enables compression
// Save or upload the encrypted file
downloadBlob(encryptedBlob, "mjkb", "example");Decrypting Files
Decrypts a .mjkb Blob and restores the original file.
import { MajikBlob } from "@thezelijah/majik-blob";
const decrypted = await MajikBlob.decryptEncryptedBlob(encryptedBlob, key, rqx);
console.log(decrypted.data); // Restored Blob
console.log(decrypted.type); // Original MIME type
console.log(decrypted.extension); // Original file extensionReading File Extension Without Decryption
Reads the original file extension without decrypting the file.
const extension = await MajikBlob.getEncryptedFileExtension(encryptedBlob);
console.log(extension); // e.g. "glb", "mp3", "png"Use Cases
- Secure file uploads before storing in cloud storage
- Obfuscated delivery of downloadable assets
- Protecting media files (audio, video, 3D models)
- Client-side encryption for creative tools
- Controlled-access file distribution systems
- DRM-adjacent workflows without heavy infrastructure
Best Practices
- Use strong, unique passwords for each file.
- Store un-hashed password/key in environment variables to prevent tampering.
- Majik Blob is ideal for obfuscating files in storage; files cannot be opened without the correct key.
- Always verify the key before decrypting to avoid corrupted files.
- Compression is optional but recommended for large files.
- AES-GCM ensures tamper detection and secure encryption.
Important: Always store the un-hashed encryption key and RQX in environment variables to prevent tampering and accidental exposure.
Contributing
Contributions, bug reports, and suggestions are welcome! Feel free to fork and open a pull request.
License
ISC — free for personal and commercial use.
Author
Made with 💙 by @thezelijah
About the Developer
- Developer: Josef Elijah Fabian
- GitHub: https://github.com/jedlsf
- Project Repository: https://github.com/jedlsf/majik-blob
Contact
- Business Email: [email protected]
- Official Website: https://www.thezelijah.world
✅ What’s new in this version:
- Highlights AES-256-GCM encryption with random IVs (replaced Fernet).
- Mentions optional compression for smaller encrypted files.
- Clarifies integrity checks and tamper detection.
- Updated usage examples to include compression parameter.

