# peter-gergely-horvath/windpapi4j architecture

> Architecture diagram of the GitHub repository peter-gergely-horvath/windpapi4j, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/peter-gergely-horvath/windpapi4j
- Repository: https://github.com/peter-gergely-horvath/windpapi4j

## Overview

WinDPAPI4J is a small Java wrapper around Windows DPAPI, exposing encryption and decryption with optional entropy, descriptions, and flags. A Java application checks platform support, creates a configured wrapper, and calls protect or unprotect; the wrapper marshals byte arrays into native blobs and invokes Windows CryptoAPI through JNA. It also uses Kernel32 for native error and memory handling and exposes exceptions for initialization or call failures. Relationships follow the README and sampled source; unsampled implementation details are not inferred.

Main entry points: [`src/main/java/com/github/windpapi4j/WinDPAPI.java`](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/WinDPAPI.java) (DPAPI wrapper), [`src/main/java/com/github/windpapi4j/Crypt32.java`](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/Crypt32.java) (CryptoAPI binding), [`src/main/java/com/github/windpapi4j/HResultException.java`](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/HResultException.java) (HRESULT errors), [`src/main/java/com/github/windpapi4j/WinCrypt.java`](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/WinCrypt.java) (Native data blobs)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_java_app(("Java application"))
node_wrapper["DPAPI wrapper<br/>[WinDPAPI.java]"]
node_blob["Native data blobs<br/>[WinCrypt.java]"]
node_crypt32_binding["CryptoAPI binding<br/>[Crypt32.java]"]
node_kernel_binding["Kernel32 binding<br/>[Kernel32.java]"]
node_windows_dpapi["Windows DPAPI"]
node_call_errors["Call exceptions"]
node_hresult_error["HRESULT errors"]
node_init_error["Initialization errors"]

node_java_app -->|"creates and calls"| node_wrapper
node_wrapper -->|"marshals bytes"| node_blob
node_wrapper -->|"invokes protect and unprotect"| node_crypt32_binding
node_crypt32_binding -->|"uses blob structures"| node_blob
node_crypt32_binding -->|"calls native API"| node_windows_dpapi
node_wrapper -->|"uses native helpers"| node_kernel_binding
node_wrapper -->|"reports call failures"| node_call_errors
node_wrapper -->|"reports HRESULT failures"| node_hresult_error
node_wrapper -->|"reports initialization failures"| node_init_error
node_hresult_error -->|"extends"| node_call_errors

click node_wrapper "https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/WinDPAPI.java"
click node_blob "https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/WinCrypt.java"
click node_crypt32_binding "https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/Crypt32.java"
click node_kernel_binding "https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/Kernel32.java"
click node_call_errors "https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/WinAPICallFailedException.java"
click node_hresult_error "https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/HResultException.java"
click node_init_error "https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/InitializationFailedException.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_java_app toneIndigo
class node_wrapper,node_crypt32_binding,node_windows_dpapi toneMint
class node_blob,node_kernel_binding,node_call_errors,node_hresult_error,node_init_error toneTeal
```

## Components

### Other components

- **Java application**
- [DPAPI wrapper](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/WinDPAPI.java): `src/main/java/com/github/windpapi4j/WinDPAPI.java`
- [Native data blobs](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/WinCrypt.java): `src/main/java/com/github/windpapi4j/WinCrypt.java`
- [CryptoAPI binding](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/Crypt32.java): `src/main/java/com/github/windpapi4j/Crypt32.java`
- [Kernel32 binding](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/Kernel32.java): `src/main/java/com/github/windpapi4j/Kernel32.java`
- **Windows DPAPI**
- [Call exceptions](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/WinAPICallFailedException.java): `src/main/java/com/github/windpapi4j/WinAPICallFailedException.java`
- [HRESULT errors](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/HResultException.java): `src/main/java/com/github/windpapi4j/HResultException.java`
- [Initialization errors](https://github.com/peter-gergely-horvath/windpapi4j/blob/master/src/main/java/com/github/windpapi4j/InitializationFailedException.java): `src/main/java/com/github/windpapi4j/InitializationFailedException.java`

## Connections

- Java application → DPAPI wrapper: creates and calls (evidence: `README.md`)
- DPAPI wrapper → Native data blobs: marshals bytes (evidence: `src/main/java/com/github/windpapi4j/WinDPAPI.java`)
- DPAPI wrapper → CryptoAPI binding: invokes protect and unprotect (evidence: `src/main/java/com/github/windpapi4j/WinDPAPI.java`)
- CryptoAPI binding → Native data blobs: uses blob structures (evidence: `src/main/java/com/github/windpapi4j/Crypt32.java`)
- CryptoAPI binding → Windows DPAPI: calls native API (evidence: `README.md`)
- DPAPI wrapper → Kernel32 binding: uses native helpers (evidence: `src/main/java/com/github/windpapi4j/WinDPAPI.java`)
- DPAPI wrapper → Call exceptions: reports call failures (evidence: `src/main/java/com/github/windpapi4j/WinDPAPI.java`)
- DPAPI wrapper → HRESULT errors: reports HRESULT failures (evidence: `src/main/java/com/github/windpapi4j/WinDPAPI.java`)
- DPAPI wrapper → Initialization errors: reports initialization failures (evidence: `src/main/java/com/github/windpapi4j/WinDPAPI.java`)
- HRESULT errors → Call exceptions: extends (evidence: `src/main/java/com/github/windpapi4j/HResultException.java`)
