β‘ Hardware-bound encryption via Windows DPAPI & persistent credentials in the Windows Credential Vault with zero-heap memory scrubbing.
FastKeychain eliminates the widespread practice of storing sensitive API tokens, application licenses, and passphrases in insecure plaintext files or raw configuration keys. It binds encrypted secrets directly to the current Windows user profile and the machine's hardware TPM 2.0 security chip, while scrubbing memory buffers immediately after use to prevent RAM dump inspection.
import fastkeychain.FastKeychain;
public class Example {
public static void main(String[] args) {
// Transparent Windows DPAPI (CryptProtectData / CryptUnprotectData)
String sensitiveToken = "sk-ant-api03-live-99882244-SECRET";
byte[] encrypted = FastKeychain.protectString(sensitiveToken);
String decrypted = FastKeychain.unprotectString(encrypted);
// Persistent Windows Credential Manager (CredWriteW / CredReadW)
FastKeychain.writeSecret("MyApp/License", "FSC-PRO-KEY-2026".getBytes());
byte[] licenseBytes = FastKeychain.readSecret("MyApp/License");
FastKeychain.deleteSecret("MyApp/License");
// Zero-allocation memory wiping
FastKeychain.wipe(licenseBytes);
}
}- Why FastKeychain?
- Key Features
- Real-World Use Cases
- Architecture & Security Pipeline
- Performance Benchmarks
- API Quick Reference
- Installation
- Technical Examples & Hero Demos
- Documentation
- Platform Support
- Related Projects
- License
Standard Java applications suffer from fundamental security vulnerabilities when handling credentials:
- Plaintext Leaks on Disk: Developers persist API keys or licenses in
.json,.properties, or.envfiles readable by any process or malware. - RAM Dump Vulnerability: Standard
java.lang.Stringinstances are immutable and remain cached in the JVM garbage collector heap indefinitely. - No Hardware Binding: Encrypted files can simply be copied to other machines without restriction.
FastKeychain solves this:
- TPM 2.0 & OS User Binding: Uses
CryptProtectData(DPAPI) β data can only be decrypted on the exact same hardware by the same logged-in Windows user. - Windows Credential Manager Integration: Native persistence via
CredWriteW/CredReadWresiding in the secure Windows Credential Vault. - Zero-String Memory Scrubbing: Automatically scrubs native buffers with
SecureZeroMemoryand primitive Java arrays withArrays.fill((byte)0).
- π‘οΈ Windows DPAPI Direct Access β Hardware-tied
CryptProtectDataandCryptUnprotectDatain sub-millisecond execution. - ποΈ Windows Vault Integration β Read, write, and delete credentials directly in the Windows Credential Manager.
- π§Ή Zero-Leak Memory Scrubbing β Immediate memory zeroization (
FastKeychain.wipe) preventing RAM forensics and heap dumps. - β‘ Zero-Copy Native Bridge β High-speed JNI bridge with zero external DLL dependencies (links directly to
Crypt32.lib&Advapi32.lib). - π FastJava Ecosystem Synergy β Seamlessly integrates with
FastCore,FastCrypto, andFastScreenCaptureApp.
- π AI Agent & LLM API Keys (FastAgent): Store Anthropic, OpenAI, or Google API keys safely in the Windows Vault without saving them in
.envor project source code. - πΌ Commercial Software License Validation: Protect and verify offline license tokens (
FSC-PRO-...) with hardware TPM anchoring so they cannot be copied to another machine. - π Master Key Storage for FastCrypto: Securely store 256-bit AES master keys and auto-unlock them at runtime without prompting the user for passwords on every start.
- π Enterprise Cloud / DB Credentials: Retrieve database connection passwords and service credentials on-demand and wipe them from RAM immediately after socket connection.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Java Application Layer β
β (FastKeychain.java) β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β JNI Bridge (< 1 Β΅s)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β fastkeychain.dll (MSVC x64) β
β βββ CryptProtectDataW / CryptUnprotectDataW β
β βββ CredWriteW / CredReadW / CredDeleteW β
β βββ SecureZeroMemory() Buffers β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β Hardware-Backed Storage
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Windows Security Subsystem & TPM 2.0 Chip β
β (DPAPI Master Keys & Credential Vault) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Empirical latency and throughput benchmarks measured on Windows 11 with hardware TPM 2.0 and Windows Credential Manager integration (run-benchmark.bat):
| Operation / Benchmark | Java Standard (.env / File / KeyStore) |
FastKeychain Hardware Native | Security & Performance Advantage |
|---|---|---|---|
| DPAPI Hardware Protect | N/A (Plaintext file / Java KeyStore) | 174.00 Β΅s (~5,750 ops/s) | Hardware TPM 2.0 + User DPAPI sealed |
| DPAPI Hardware Unprotect | N/A (Plaintext in JVM heap) | 144.54 Β΅s (~6,920 ops/s) | Instant unseal; 0 offline disk extraction |
| Windows Vault Write + Read | ~15β40 ms (Disk file I/O + JSON parsing) | 5.75 ms (~175 cycles/s) | Persistent, encrypted OS Credential Vault |
| Memory Sanitization | Non-scrubbed (String immutable in GC) |
< 0.05 Β΅s (SecureZeroMemory) |
100% RAM Forensics & Heap Dump Immunity |
Note
Environment & Setup: Measured on a Microsoft Surface Pro 8 (11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz, 4C/8T), Windows 11 Home (x64), OpenJDK 21 LTS with hardware TPM 2.0 chip and Windows Hello security subsystem. Standard Java stores strings in GC heap memory where they persist indefinitely; FastKeychain integrates with bare-metal Windows kernel DPAPI and zeroizes native memory immediately upon cryptographic consumption.
| Method | Return Type | Description |
|---|---|---|
protectData(byte[] data, byte[] entropy) |
byte[] |
Encrypts raw byte array via Windows DPAPI |
unprotectData(byte[] data, byte[] entropy) |
byte[] |
Decrypts DPAPI ciphertext byte array |
protectString(String secret) |
byte[] |
Convenience method: Encrypts UTF-8 string with DPAPI |
unprotectString(byte[] ciphertext) |
String |
Convenience method: Decrypts DPAPI ciphertext to String |
writeSecret(String target, byte[] secret) |
boolean |
Persists generic credential into Windows Vault |
readSecret(String target) |
byte[] |
Reads generic credential from Windows Vault |
deleteSecret(String target) |
boolean |
Removes credential from Windows Vault |
wipe(byte[] secret) |
void |
Overwrites memory buffer with 0x00 via SecureZeroMemory |
FastKeychain is distributed via JitPack. It requires FastCore as the unified native library loader.
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastKeychain Core -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastKeychain</artifactId>
<version>0.1.0</version>
</dependency>
<!-- FastCore Native Loader -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastKeychain:0.1.0'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the latest pre-compiled JARs:
- π¦ FastKeychain-0.1.0.jar
- βοΈ FastCore-0.1.0.jar
| Example / Demo | Description | Path | Run Command |
|---|---|---|---|
| Interactive Showcase Demo | Complete round-trip lifecycle demo showcasing DPAPI token sealing, Credential Vault persistence, and RAM scrubbing. | examples/Demo/Demo.java |
run-demo.bat |
| Microsecond Benchmarks | High-precision performance suite measuring hardware encryption latency and ops/sec. | examples/Benchmark/Benchmark.java |
run-benchmark.bat |
- REFERENCE.md: Full API descriptions and security contracts.
- PHILOSOPHY.md: The engineering rationale for hardware-anchored zero-heap security.
- ROADMAP.md: Future milestones (DPAPI-NG, macOS Keychain, Linux Secret Service).
- CHANGELOG.md: Detailed version history.
| Platform | Hardware Security | Status |
|---|---|---|
| Windows 10 / 11 (x64) | TPM 2.0 / DPAPI / Credential Vault | β Fully Supported |
| Windows Server 2016+ (x64) | TPM / DPAPI / Credential Vault | β Fully Supported |
| macOS / Linux | Under Development (v0.5.0) | π§ Planned |
- FastCrypto β Hardware-accelerated AES-GCM & SIMD cryptography
- FastCore β Native library loader with local fallback
- FastScreen β DirectX DXGI screen capture engine
- FastTheme β Windows native window styling & DWM theme engine
MIT License β See LICENSE for details.
Part of the FastJava Ecosystem β Making the JVM faster. β‘