Welcome

Quality Gate Statusarrow-up-right Security Ratingarrow-up-right Vulnerabilitiesarrow-up-right Maven Centralarrow-up-right Licensearrow-up-right

Bruce is an ergonomic, lightweight, pure Java wrapper around the Java Cryptography Architecture (JCA)arrow-up-right. It makes common cryptographic operations straightforward without adding any runtime dependencies beyond the JDK.

Features

  • Digital signatures — sign and verify data with RSA, DSA, ECDSA, and more

  • Symmetric encryption — AES-CBC, AES-GCM, DES, and other secret-key ciphers

  • Asymmetric encryption — RSA public/private-key encryption and decryption

  • Message digests — SHA-256, SHA-512, MD5, and any JCA-supported algorithm

  • Message Authentication Codes (MAC) — HmacSHA256, HmacSHA512, and more

  • Keystore management — load PKCS12/JKS keystores from classpath, file, HTTP(S)

  • Key generation — generate RSA/DSA/EC key pairs and symmetric keys on the fly

  • PEM support — read and write private keys, public keys, and certificates in PEM format

  • Multiple encodings — HEX, BASE64, URL-safe BASE64, and MIME BASE64

  • Pluggable providers — works with any JCA provider (e.g., Bouncy Castlearrow-up-right)

  • Multi-key APIs — select a key by ID at call time for key-rotation scenarios

  • Zero runtime dependencies — pure JDK, no extra JARs required at runtime

Requirements

  • Java 21 or later

Installation

Maven

Gradle

Check Maven Centralarrow-up-right for the latest release version.

Quick Start

All operations are accessed through two static facades. Add these imports once at the top of your file:

Usage Examples

Loading Keys from a Keystore

Keystores can be loaded from multiple sources:

Prefix
Example

classpath:

classpath:keystore.p12

file:

file:/etc/ssl/keystore.p12

http://

http://config-server/keystore.p12

https://

https://config-server/keystore.p12

Digital Signatures

Message Digest (Hashing)

Symmetric Encryption (AES)

Asymmetric Encryption (RSA)

Message Authentication Code (MAC)

PEM Support

Key Generation

Multi-Key APIs

Bruce supports selecting a key by ID at runtime, which is useful for key-rotation scenarios:

Using a Custom Provider

The Bytes Type

Bytes is Bruce's universal currency type. It wraps a raw byte array and provides convenient conversions:

Building from Source

Run tests:

Generate Javadoc:

License

Bruce is released under the Apache License, Version 2.0arrow-up-right.

Last updated

Was this helpful?