rustcrypt-jasypt 1.0.0

Jasypt-compatible ENC(...) encryption for Rust configs: AES-256-GCM, PBEWithMD5AndDES and PBEWithHmacSHA256AndAES_256, cross-compatible with GoCrypt, PyCrypt, NodeCrypt and PHPCrypt
Documentation

RustCrypt ๐Ÿฆ€๐Ÿ”

Crates.io docs.rs CI MSRV License

Jasypt-like encryption library for Rust - Encrypt your application configuration with the familiar ENC(...) pattern used in Spring Boot applications, and share it with Go, Python, Node.js, PHP and Java.

Made with โค๏ธ from Claude AI for Rust developers who need Jasypt


๐ŸŽฏ Why RustCrypt?

If you are coming from the Java/Spring Boot world, or you run services in several languages that must read the same encrypted configuration, RustCrypt is for you! It provides:

  • โœ… Familiar ENC(...) pattern - Just like Jasypt in Spring Boot
  • โœ… Cross-language - Byte-compatible with GoCrypt, PyCrypt, NodeCrypt, PHPCrypt and Java Jasypt
  • โœ… Multiple algorithms - From legacy Jasypt compatibility to modern AES-256-GCM
  • โœ… Pure Rust - RustCrypto crates only; no OpenSSL, no C build step, DES works everywhere
  • โœ… Config loaders - .env, YAML and JSON with automatic decryption
  • โœ… CLI tool included - rustcrypt mirrors gocrypt-cli
  • โœ… Tested against GoCrypt - golden vectors generated by the reference implementation

๐Ÿ”— Cross-Language Family (ALL SAME ENC() FORMAT!)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              Jasypt Multi-Language Encryption Family             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                  โ”‚
โ”‚   ๐Ÿน GoCrypt     github.com/farizfadian/gocrypt     (Go)        โ”‚
โ”‚   ๐Ÿ PyCrypt     github.com/farizfadian/pycrypt     (Python)    โ”‚
โ”‚   ๐Ÿ“ฆ NodeCrypt   github.com/farizfadian/nodecrypt   (Node.js)   โ”‚
โ”‚   ๐Ÿ˜ PHPCrypt    github.com/farizfadian/phpcrypt    (PHP)       โ”‚
โ”‚   ๐Ÿฆ€ RustCrypt   github.com/farizfadian/rustcrypt   (Rust)      โ”‚
โ”‚   โ˜• Jasypt      jasypt.org                         (Java)      โ”‚
โ”‚                                                                  โ”‚
โ”‚   ALL USE THE SAME ENC(...) FORMAT!                             โ”‚
โ”‚                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Library Language Install
GoCrypt Go 1.21+ go get github.com/farizfadian/gocrypt
PyCrypt Python 3.8+ pip install pycrypt-jasypt
NodeCrypt Node 18+ npm i nodecrypt-jasypt
PHPCrypt PHP 8.1+ composer require farizfadian/phpcrypt
RustCrypt Rust 1.75+ cargo add rustcrypt-jasypt
Jasypt Java Maven org.jasypt:jasypt

๐Ÿ“ฆ Installation

cargo add rustcrypt-jasypt

Or in Cargo.toml:

[dependencies]
rustcrypt-jasypt = "1.0"

# Library only (no ConfigLoader, no CLI dependencies):
rustcrypt-jasypt = { version = "1.0", default-features = false }

The crate name on crates.io is rustcrypt-jasypt; in code it is rustcrypt_jasypt.

Install the CLI:

cargo install rustcrypt-jasypt

๐Ÿš€ Quick Start

Basic Encryption/Decryption

use rustcrypt_jasypt::Encryptor;

fn main() -> rustcrypt_jasypt::Result<()> {
    // Create encryptor with password (read it from the environment in real code)
    let enc = Encryptor::new("mySecretPassword")?;

    // Encrypt
    let encrypted = enc.encrypt_with_prefix("db_password_123")?;
    println!("{encrypted}"); // ENC(base64encodedvalue...)

    // Decrypt
    let decrypted = enc.decrypt_prefixed(&encrypted)?;
    println!("{decrypted}"); // db_password_123
    Ok(())
}

Loading Encrypted Configuration

use rustcrypt_jasypt::ConfigLoader;

// .env file:
// DATABASE_HOST=localhost
// DATABASE_PASSWORD=ENC(AbCdEf123456...)

let loader = ConfigLoader::new(&std::env::var("RUSTCRYPT_PASSWORD")?)?;
let config = loader.load_env_file(".env")?;

println!("{}", config["DATABASE_PASSWORD"]); // actual_password

๐Ÿ” Encryption Algorithms

RustCrypt provides three encryptors for different use cases:

Encryptor Algorithm Security Java compatible? Use Case
Encryptor AES-256-GCM + PBKDF2-HMAC-SHA256 โญโญโญโญโญ โŒ No Recommended when only family members read the value
JasyptStrongEncryptor PBKDF2-HMAC-SHA256 + AES-256-CBC โญโญโญโญ family format Stronger Jasypt-style mode shared inside the family
JasyptEncryptor PBEWithMD5AndDES โญโญ โœ… Yes Legacy Jasypt compatibility (Java)

Which encryptor should I use?

use rustcrypt_jasypt::{Encryptor, JasyptEncryptor, JasyptStrongEncryptor};

// โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
// RECOMMENDED: only Rust/Go/Python/Node/PHP services read the value
// โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
let enc = Encryptor::new(password)?;

// โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
// The value is shared with Java Jasypt (default algorithm), e.g. a JasperReport service
// โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
let enc = JasyptEncryptor::new(password)?;

// โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
// Stronger Jasypt-style mode, shared inside the family
// โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
let enc = JasyptStrongEncryptor::new(password)?;

Rule of thumb: when a Java service (for example JasperReport) reads the same .env, always use JasyptEncryptor. Encryptor values cannot be read by Java.


๐Ÿ“– Usage Guide

1. Configuration Files

.env File

# config.env
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_PASSWORD=ENC(AbCdEf123456...)
API_KEY=ENC(XyZ789...)
let loader = ConfigLoader::new(&password)?;
let config = loader.load_env_file("config.env")?;
println!("{}", config["DATABASE_PASSWORD"]); // decrypted value

YAML File (flat, same limitation as GoCrypt)

# config.yaml
database:
  host: localhost
  password: ENC(AbCdEf123456...)
let config = loader.load_yaml("config.yaml")?;
println!("{}", config["password"]); // keys are flattened

JSON File (serde, nested objects and arrays)

use serde::Deserialize;

#[derive(Deserialize)]
struct Database { host: String, password: String }

#[derive(Deserialize)]
struct Config { database: Database, api_keys: Vec<String> }

let config: Config = loader.load_json("config.json")?;
println!("{}", config.database.password);

Every ENC(...) string at any depth is decrypted; strings that fail to decrypt are kept as-is.

Jasypt mode for files shared with Java

use rustcrypt_jasypt::{ConfigLoader, JasyptEncryptor};

let loader = ConfigLoader::with_encryptor(JasyptEncryptor::new(&password)?);
let config = loader.load_env_file(".env")?;

2. Set to Environment Variables

let loader = ConfigLoader::new(&password)?;
loader.set_to_env(".env")?; // load and export every pair (call during start-up)

let db_password = std::env::var("DATABASE_PASSWORD")?;

3. Decrypt Map

use std::collections::HashMap;

let mut config = HashMap::new();
config.insert("host".to_string(), "localhost".to_string());
config.insert("password".to_string(), "ENC(encrypted_value)".to_string());

let decrypted = enc.decrypt_map(&config)?;
println!("{}", decrypted["password"]); // plaintext

4. Decrypt All in String

let input = "\
DATABASE_HOST=localhost
DATABASE_PASSWORD=ENC(encrypted_value)
API_KEY=ENC(another_encrypted_value)
";

let decrypted = enc.decrypt_all_in_string(input)?;       // Err on the first failure (GoCrypt semantics)
let best_effort = enc.decrypt_all_in_string_lossy(input);  // keeps failing ENC(...) verbatim

5. Check if Value is Encrypted

use rustcrypt_jasypt::is_encrypted;

if is_encrypted(&value) {
    let decrypted = enc.decrypt_prefixed(&value)?;
}

6. Generic code

All encryptors implement the StringEncryptor trait:

use rustcrypt_jasypt::StringEncryptor;

fn decrypt_config<E: StringEncryptor>(enc: &E, value: &str) -> rustcrypt_jasypt::Result<String> {
    enc.decrypt_prefixed(value)
}

let boxed: Box<dyn StringEncryptor> = Box::new(JasyptEncryptor::new(&password)?);

๐Ÿ’ป CLI Tool

cargo install rustcrypt-jasypt      # installs the `rustcrypt` binary
# or download a release archive from GitHub Releases
# Encrypt a value
rustcrypt encrypt -p mySecret -v "database_password"
# Output: ENC(base64value...)

# Decrypt a value
rustcrypt decrypt -p mySecret -v "ENC(base64value...)"
# Output: database_password

# Encrypt all KEY=VALUE values in a file
rustcrypt encrypt-file -p mySecret -i .env.plain -o .env.encrypted

# Decrypt all ENC(...) values in a file (omit -o or use "-" for stdout)
rustcrypt decrypt-file -p mySecret -i .env.encrypted -o .env.plain

# Use the Java Jasypt compatible algorithm
rustcrypt encrypt -p mySecret -v "secret" --jasypt

# Use the strong algorithm
rustcrypt encrypt -p mySecret -v "secret" --jasypt-strong

# Raw base64 without the ENC(...) wrapper
rustcrypt encrypt -p mySecret -v "secret" --no-prefix

# Use an environment variable for the password
export RUSTCRYPT_PASSWORD=mySecret
rustcrypt encrypt -v "secret_value"

The commands, flags, messages and exit codes mirror gocrypt-cli, pycrypt and nodecrypt.


โ˜• Cross-Language Compatibility

Compatibility Matrix

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            ENCRYPT WITH โ†’ DECRYPT WITH                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Java Jasypt (default)  โ†’ JasyptEncryptor           โœ… YES       โ”‚
โ”‚ GoCrypt JasyptEnc      โ†’ JasyptEncryptor           โœ… YES       โ”‚
โ”‚ PyCrypt JasyptEnc      โ†’ JasyptEncryptor           โœ… YES       โ”‚
โ”‚ NodeCrypt JasyptEnc    โ†’ JasyptEncryptor           โœ… YES       โ”‚
โ”‚ PHPCrypt JasyptEnc     โ†’ JasyptEncryptor           โœ… YES       โ”‚
โ”‚ GoCrypt Encryptor      โ†’ Encryptor                 โœ… YES       โ”‚
โ”‚ GoCrypt StrongEnc      โ†’ JasyptStrongEncryptor     โœ… YES       โ”‚
โ”‚ JasyptEncryptor        โ†’ Java Jasypt               โœ… YES       โ”‚
โ”‚ Encryptor              โ†’ Java Jasypt               โŒ NO        โ”‚
โ”‚ Java Jasypt (default)  โ†’ Encryptor                 โŒ NO        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Example: encrypt in Go, decrypt in Rust

// Go (GoCrypt)
enc, _ := gocrypt.NewJasyptEncryptor("sharedPassword")
value, _ := enc.EncryptWithPrefix("hello")   // ENC(sIAlbZnxY3KGqbnsHk+t2w==)
// Rust (RustCrypt)
use rustcrypt_jasypt::JasyptEncryptor;

let enc = JasyptEncryptor::new("sharedPassword")?;
let plaintext = enc.decrypt_prefixed("ENC(sIAlbZnxY3KGqbnsHk+t2w==)")?; // "hello"
# Python (PyCrypt)
from pycrypt_jasypt import JasyptEncryptor
JasyptEncryptor(password="sharedPassword").decrypt_prefixed("ENC(sIAlbZnxY3KGqbnsHk+t2w==)")  # "hello"
// Java (Jasypt)
StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
enc.setPassword("sharedPassword");
enc.setAlgorithm("PBEWithMD5AndDES");
enc.decrypt("sIAlbZnxY3KGqbnsHk+t2w==");   // "hello"

Requirement: every side must use the same password and the same algorithm (and the same iteration count / salt size when customised).

How compatibility is verified

  • tests/fixtures/gocrypt_vectors.json holds values produced by GoCrypt v1.0.0 for all three modes (ASCII, punctuation, 200 characters, UTF-8 with emoji), plus fixed-salt vectors computed with GoCrypt's own KDF and cipher code. cargo test asserts that RustCrypt decrypts every one of them and reproduces the fixed-salt outputs byte-for-byte.
  • cargo test -- --ignored (with gocrypt-cli on PATH or GOCRYPT_CLI=/path/to/gocrypt-cli) round-trips live in both directions.
  • scripts/cross-check.ps1 runs the same round trips against gocrypt-cli, pycrypt and nodecrypt when they are installed.

โš™๏ธ Advanced Configuration

// AES-256-GCM
let enc = Encryptor::new(password)?
    .with_iterations(50_000)   // default: 10_000
    .with_salt_size(32)        // default: 16
    .with_key_size(32)?;       // 16 = AES-128, 24 = AES-192, 32 = AES-256 (default)

// Jasypt compatible: match the Java side's keyObtentionIterations
let enc = JasyptEncryptor::new(password)?
    .with_iterations(2_000);   // default: 1_000

// Jasypt strong
let enc = JasyptStrongEncryptor::new(password)?
    .with_iterations(5_000)    // default: 1_000
    .with_salt_size(32);       // default: 16

Parameters are not stored in the ciphertext, so both sides must use the same values.


๐Ÿ›ก๏ธ Security

Algorithm Comparison

Algorithm Cipher Key Derivation Integrity Security
Encryptor AES-256-GCM PBKDF2-HMAC-SHA256 (10 000) AEAD tag โœ… Strong
JasyptStrongEncryptor AES-256-CBC PBKDF2-HMAC-SHA256 (1 000) none (padding only) โœ… Good
JasyptEncryptor DES-CBC PBKDF1-MD5 (1 000) none (padding only) โš ๏ธ Legacy

Best Practices

  1. Never hardcode passwords - Use environment variables (RUSTCRYPT_PASSWORD)
  2. Rotate passwords regularly
  3. Use strong passwords (minimum 16 characters)
  4. Store encrypted config in version control, not plaintext
  5. Use Encryptor unless Java must read the value - it is the only mode with authentication

Please report vulnerabilities as described in SECURITY.md.


โš ๏ธ Known Issues

  • JasyptStrongEncryptor is not byte-identical to Java Jasypt's PBEWithHmacSHA256AndAES_256. Real Jasypt prepends a random IV (salt โ€– iv โ€– ciphertext); the family format derives the IV from PBKDF2 (salt โ€– ciphertext). It is fully interoperable with GoCrypt, PyCrypt, NodeCrypt and PHPCrypt, and will only change in a coordinated release of all five libraries.
  • JasyptEncryptor uses DES and MD5, which are weak by modern standards, and DES-CBC has no integrity check: decrypting with a wrong password usually fails with Error::DecryptionFailed but can occasionally return garbage. Use it for Java compatibility only.
  • ConfigLoader::set_to_env mutates the process environment. Call it during single-threaded start-up, before other threads read environment variables.
  • load_yaml is a flat line parser (key: value), the same simplification as GoCrypt. Use a YAML crate plus decrypt_map for complex documents.

๐Ÿ“š API Reference

Full documentation: https://docs.rs/rustcrypt-jasypt

// Constructors (all return Result; empty password -> Error::EmptyPassword)
Encryptor::new(password)             .with_iterations(u32) .with_salt_size(usize) .with_key_size(usize)?
JasyptEncryptor::new(password)       .with_iterations(u32)
JasyptStrongEncryptor::new(password) .with_iterations(u32) .with_salt_size(usize)

// Methods (inherent on every encryptor and on the StringEncryptor trait)
fn encrypt(&self, plaintext: &str) -> Result<String>                 // base64
fn encrypt_with_prefix(&self, plaintext: &str) -> Result<String>     // ENC(base64)
fn decrypt(&self, encoded: &str) -> Result<String>
fn decrypt_prefixed(&self, value: &str) -> Result<String>
fn decrypt_all_in_string(&self, input: &str) -> Result<String>
fn decrypt_all_in_string_lossy(&self, input: &str) -> String
fn decrypt_map(&self, map: &HashMap<String, String>) -> Result<HashMap<String, String>>

// Helpers
fn is_encrypted(value: &str) -> bool
const ENC_PREFIX: &str = "ENC(";
const ENC_SUFFIX: &str = ")";

// ConfigLoader (feature "config", default)
ConfigLoader::new(password) -> Result<ConfigLoader<Encryptor>>
ConfigLoader::with_encryptor(enc) -> ConfigLoader<E>
fn load_env_file(&self, path) -> Result<HashMap<String, String>>
fn load_yaml(&self, path) -> Result<HashMap<String, String>>
fn load_json<T: DeserializeOwned>(&self, path) -> Result<T>
fn decrypt_json_value(&self, value: &mut serde_json::Value)
fn set_to_env(&self, path) -> Result<()>

// Errors (thiserror, #[non_exhaustive])
Error::{EmptyPassword, EmptyValue, InvalidEncFormat, InvalidJasyptData, DecryptionFailed,
        Base64(_), Io(_), Json(_), KeyDecrypt { key, source }, InvalidParameter(_)}

๐Ÿ“ Project Structure

rustcrypt/
โ”œโ”€โ”€ Cargo.toml                 # crate: rustcrypt-jasypt, bin: rustcrypt
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ lib.rs                 # crate docs + re-exports
โ”‚   โ”œโ”€โ”€ error.rs               # Error / Result
โ”‚   โ”œโ”€โ”€ kdf.rs                 # PBKDF2-HMAC-SHA256, PBKDF1-MD5
โ”‚   โ”œโ”€โ”€ prefix.rs              # ENC(...) helpers + StringEncryptor trait
โ”‚   โ”œโ”€โ”€ encryptor.rs           # Encryptor (AES-256-GCM)
โ”‚   โ”œโ”€โ”€ jasypt.rs              # JasyptEncryptor + JasyptStrongEncryptor
โ”‚   โ”œโ”€โ”€ config_loader.rs       # ConfigLoader (feature "config")
โ”‚   โ”œโ”€โ”€ golden.rs              # fixed-salt tests against GoCrypt vectors
โ”‚   โ””โ”€โ”€ bin/rustcrypt.rs       # CLI (feature "cli")
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ roundtrip.rs           # round trips, tampering, error paths
โ”‚   โ”œโ”€โ”€ cross_language.rs      # GoCrypt golden vectors + live gocrypt-cli
โ”‚   โ”œโ”€โ”€ config_loader.rs
โ”‚   โ”œโ”€โ”€ cli.rs
โ”‚   โ””โ”€โ”€ fixtures/gocrypt_vectors.json
โ”œโ”€โ”€ examples/                  # basic, jasypt_compat, config_loader
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ gen-vectors/           # Go program that regenerates the fixture
โ”‚   โ””โ”€โ”€ cross-check.ps1        # round trips against sibling CLIs
โ””โ”€โ”€ .github/workflows/         # ci.yml, release.yml

๐Ÿงช Testing

cargo test --all-features                          # unit + integration + doctests
cargo test --no-default-features                   # library only
cargo test -- --ignored                            # live round trips with gocrypt-cli
cargo clippy --all-targets --all-features -- -D warnings
cargo +1.75.0 test --all-features --locked         # MSRV

# Regenerate the GoCrypt fixture (needs Go)
cd scripts/gen-vectors && go run . -commit <gocrypt commit> -out ../../tests/fixtures/gocrypt_vectors.json

๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md first.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Anything that changes a wire format must stay byte-compatible with GoCrypt.


๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments