magic-crypt

AES and DES string, file, and data encryption for Rust with cross-language compatibility.

Library
Cargo
v5.0.1
37stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
41/100Fair
Development Activity48
Maintenance20
Community24
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture78
Code Quality74
Innovation70
Learning Curve86

MagicCrypt is a Rust implementation of the cross-language MagicCrypt family (also available for Java, PHP, and Node.js) for encrypting and decrypting strings, files, and streams. It supports both DES and AES in CBC mode with PKCS7 padding and key lengths of 64, 128, 192, or 256 bits, and can read and write Base64 directly for convenient string handling.

The crate offers a compact API built around a MagicCrypt value and a set of encrypt/decrypt methods, including reader-to-writer variants for large data. Note that MagicCrypt uses an older, unauthenticated encryption design; its maintainers recommend a modern authenticated-encryption library for new projects, but it remains useful for interoperating with existing MagicCrypt data across languages.

What You Get

  • AES and DES encryption in CBC mode with PKCS7 padding
  • Selectable key lengths of 64, 128, 192, or 256 bits
  • Convenience methods that encrypt/decrypt directly to and from Base64
  • Reader-to-writer methods with configurable buffer size for large files and streams
  • Cross-language compatibility with the Java, PHP, and Node.js MagicCrypt implementations

Common Use Cases

  • Encrypting short strings or tokens to Base64 for storage or transport
  • Decrypting data produced by MagicCrypt in another language such as Java or PHP
  • Streaming encryption of larger files via reader-to-writer methods

Under The Hood

Architecture - The crate is centered on a MagicCrypt type and a MagicCryptTrait (src/traits.rs, src/lib.rs), with per-algorithm implementations under src/ciphers, macro helpers in src/macros.rs, and error types in src/errors.rs. Convenience constructors like new_magic_crypt! wrap key/IV derivation. Tech Stack - Rust edition 2024 (MSRV 1.87), building on the RustCrypto ecosystem: aes, des, cbc, sha2, md-5, tiger for hashing, base64 for encoding, crc-any, and zeroize for wiping sensitive buffers. A default std feature can be disabled for no_std/alloc use. Code Quality - The repo ships a tests/ directory and CI workflow, and prominently documents a security notice steering users toward authenticated encryption for new work, indicating honest maintenance. API Design - The public API is small and ergonomic: build a MagicCrypt with a key and bit length, then call encrypt_str_to_base64 / decrypt_base64_to_string or the reader-to-writer variants, keeping typical usage to a couple of lines.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search