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.
Click the image to try Majik Blob.
- 🔐 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
npm i @thezelijah/majik-blobEncrypts 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 passwordOptionally 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");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 extensionReads the original file extension without decrypting the file.
const extension = await MajikBlob.getEncryptedFileExtension(encryptedBlob);
console.log(extension); // e.g. "glb", "mp3", "png"- 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
- 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.
Contributions, bug reports, and suggestions are welcome! Feel free to fork and open a pull request.
ISC — free for personal and commercial use.
Made with 💙 by @thezelijah
- Developer: Josef Elijah Fabian
- GitHub: https://github.com/jedlsf
- Project Repository: https://github.com/jedlsf/majik-blob
- Business Email: business@thezelijah.world
- 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.
