# valinom/aes256bit architecture

> Architecture diagram of the GitHub repository valinom/aes256bit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/valinom/aes256bit
- Repository: https://github.com/valinom/aes256bit

## Overview

This is a fully offline browser tool for encrypting and decrypting text and files with password-derived AES-GCM keys. Users provide text or select a file, enter a passphrase, and trigger an operation; results are encoded or downloaded locally. The main script owns UI event handling, payload preparation, cryptographic calls, and output. The excerpts show these responsibilities, but omit portions of the implementation, so links for unsampled details rely on README statements.

Main entry points: [`js/main.js`](https://github.com/valinom/aes256bit/blob/main/js/main.js) (AES-GCM payload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Text interaction"]
  node_text_ui["Text controls<br/>[main.js]"]
  node_text_codec["Text encoding<br/>[main.js]"]
end

subgraph group_cryptography["Cryptography"]
  node_key_derivation["PBKDF2 key derivation<br/>[main.js]"]
  node_aes_payload["AES-GCM payload<br/>[main.js]"]
end

subgraph group_file["File handling"]
  node_file_ui["File controls<br/>[main.js]"]
  node_file_payload["File metadata payload<br/>[main.js]"]
end

node_user(("User"))
node_webcrypto["WebCrypto API"]
node_local_browser["Local browser files"]
node_download["Downloaded output"]

node_user -->|"enters text"| node_text_ui
node_text_ui -->|"encodes input"| node_text_codec
node_text_ui -->|"encrypts or decrypts"| node_aes_payload
node_text_codec -->|"formats result"| node_text_ui
node_user -->|"selects file"| node_file_ui
node_file_ui -->|"prepares file data"| node_file_payload
node_file_ui -->|"encrypts or decrypts"| node_aes_payload
node_file_payload -->|"supplies payload"| node_aes_payload
node_aes_payload -->|"restores file data"| node_file_payload
node_aes_payload -->|"derives key"| node_key_derivation
node_key_derivation -->|"uses PBKDF2"| node_webcrypto
node_aes_payload -->|"uses AES-GCM"| node_webcrypto
node_file_ui -->|"reads selected file"| node_local_browser
node_text_ui -->|"downloads text"| node_download
node_file_ui -->|"downloads file"| node_download
node_user -->|"loads encrypted file"| node_local_browser

click node_text_ui "https://github.com/valinom/aes256bit/blob/main/js/main.js"
click node_text_codec "https://github.com/valinom/aes256bit/blob/main/js/main.js"
click node_file_ui "https://github.com/valinom/aes256bit/blob/main/js/main.js"
click node_file_payload "https://github.com/valinom/aes256bit/blob/main/js/main.js"
click node_key_derivation "https://github.com/valinom/aes256bit/blob/main/js/main.js"
click node_aes_payload "https://github.com/valinom/aes256bit/blob/main/js/main.js"

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_text_ui,node_text_codec,node_user,node_local_browser toneBlue
class node_key_derivation,node_aes_payload toneAmber
class node_file_ui,node_file_payload,node_webcrypto toneMint
class node_download toneIndigo
```

## Components

### Text interaction

- [Text controls](https://github.com/valinom/aes256bit/blob/main/js/main.js): `js/main.js`
- [Text encoding](https://github.com/valinom/aes256bit/blob/main/js/main.js): `js/main.js`

### Cryptography

- [PBKDF2 key derivation](https://github.com/valinom/aes256bit/blob/main/js/main.js): `js/main.js`
- [AES-GCM payload](https://github.com/valinom/aes256bit/blob/main/js/main.js): `js/main.js`

### File handling

- [File controls](https://github.com/valinom/aes256bit/blob/main/js/main.js): `js/main.js`
- [File metadata payload](https://github.com/valinom/aes256bit/blob/main/js/main.js): `js/main.js`

### Other components

- **User**
- **WebCrypto API**
- **Local browser files**
- **Downloaded output**

## Connections

- User → Text controls: enters text (evidence: `js/main.js`)
- Text controls → Text encoding: encodes input (evidence: `js/main.js`)
- Text controls → AES-GCM payload: encrypts or decrypts (evidence: `js/main.js`)
- Text encoding → Text controls: formats result (evidence: `js/main.js`)
- User → File controls: selects file (evidence: `js/main.js`)
- File controls → File metadata payload: prepares file data (evidence: `js/main.js`)
- File controls → AES-GCM payload: encrypts or decrypts (evidence: `js/main.js`)
- File metadata payload → AES-GCM payload: supplies payload (evidence: `js/main.js`)
- AES-GCM payload → File metadata payload: restores file data (evidence: `js/main.js`)
- AES-GCM payload → PBKDF2 key derivation: derives key (evidence: `js/main.js`)
- PBKDF2 key derivation → WebCrypto API: uses PBKDF2 (evidence: `js/main.js`)
- AES-GCM payload → WebCrypto API: uses AES-GCM (evidence: `js/main.js`)
- File controls → Local browser files: reads selected file (evidence: `js/main.js`)
- Text controls → Downloaded output: downloads text (evidence: `js/main.js`)
- File controls → Downloaded output: downloads file (evidence: `js/main.js`)
- User → Local browser files: loads encrypted file
