# kokinf/cryptocore architecture

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

- Interactive diagram: https://gitdiagram.com/kokinf/cryptocore
- Repository: https://github.com/kokinf/cryptocore

## Overview

CryptoCore is a command-line cryptography utility. The main workflow parses a user command, processes an input file through encryption/decryption, hashing or key derivation, and optionally writes a result. Its cryptographic capabilities include AES modes, authenticated encryption, HMAC, SHA-256/SHA3-256, and PBKDF2/HKDF-style derivation. The graph reflects calls visible in excerpts and relationships documented in the README; some operation implementations were not sampled, so those links rely on README evidence rather than inspected source.

Main entry points: [`src/file_io.go`](https://github.com/kokinf/cryptocore/blob/main/src/file_io.go) (File operations), [`src/main.go`](https://github.com/kokinf/cryptocore/blob/main/src/main.go) (Hash operation), [`src/modes`](https://github.com/kokinf/cryptocore/tree/main/src/modes) (AES modes), [`src/mac/hmac.go`](https://github.com/kokinf/cryptocore/blob/main/src/mac/hmac.go) (HMAC)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command line"]
  node_entry["Command entry<br/>[main.go]"]
  node_parser["Argument parser<br/>[cli_parser.go]"]
  node_fileops["File operations<br/>[file_io.go]"]
end

subgraph group_crypto["Encryption"]
  node_modes["AES modes"]
  node_cbc["CBC mode<br/>[cbc.go]"]
  node_ecb["ECB mode<br/>[ecb.go]"]
  node_othermodes["CFB CTR OFB"]
  node_gcm["GCM AEAD<br/>[gcm.go]"]
  node_etm["Encrypt-then-MAC"]
  node_random["Secure randomness<br/>[csprng.go]"]
end

subgraph group_integrity["Integrity"]
  node_hashop["Hash operation<br/>[main.go]"]
  node_hash256["SHA-256<br/>[sha256.go]"]
  node_hash3["SHA3-256<br/>[sha3.go]"]
  node_hmac["HMAC<br/>[hmac.go]"]
end

subgraph group_keys["Key derivation"]
  node_deriveop["Derive operation<br/>[file_io.go]"]
  node_pbkdf2["PBKDF2<br/>[pbkdf2.go]"]
  node_hkdf["HKDF-style derivation<br/>[hkdf.go]"]
end

node_user(("CLI user"))
node_files["Input/output files"]

node_user -->|"provides flags"| node_parser
node_entry -->|"parses arguments"| node_parser
node_entry -->|"dispatches crypto"| node_fileops
node_entry -->|"dispatches hash"| node_hashop
node_entry -->|"dispatches derive"| node_deriveop
node_fileops -->|"reads and writes"| node_files
node_fileops -->|"processes AES files"| node_modes
node_fileops -->|"uses AEAD"| node_gcm
node_fileops -->|"uses AEAD"| node_etm
node_modes -->|"includes"| node_cbc
node_modes -->|"includes"| node_ecb
node_modes -->|"includes"| node_othermodes
node_gcm -->|"generates nonce"| node_random
node_etm -->|"encrypts with"| node_modes
node_etm -->|"computes MAC"| node_hmac
node_hashop -->|"hashes input"| node_files
node_hashop -->|"computes digest"| node_hash256
node_hashop -->|"computes digest"| node_hash3
node_hashop -->|"supports HMAC"| node_hmac
node_hmac -->|"uses SHA-256"| node_hash256
node_deriveop -->|"derives key"| node_pbkdf2
node_deriveop -->|"offers key hierarchy"| node_hkdf
node_hkdf -->|"computes blocks"| node_hmac
node_deriveop -->|"generates salt"| node_random

click node_entry "https://github.com/kokinf/cryptocore/blob/main/src/main.go"
click node_parser "https://github.com/kokinf/cryptocore/blob/main/src/cli_parser.go"
click node_fileops "https://github.com/kokinf/cryptocore/blob/main/src/file_io.go"
click node_modes "https://github.com/kokinf/cryptocore/tree/main/src/modes"
click node_cbc "https://github.com/kokinf/cryptocore/blob/main/src/modes/cbc.go"
click node_ecb "https://github.com/kokinf/cryptocore/blob/main/src/modes/ecb.go"
click node_othermodes "https://github.com/kokinf/cryptocore/tree/main/src/modes"
click node_gcm "https://github.com/kokinf/cryptocore/blob/main/src/aead/gcm.go"
click node_etm "https://github.com/kokinf/cryptocore/blob/main/src/aead/encrypt_then_mac.go"
click node_hashop "https://github.com/kokinf/cryptocore/blob/main/src/main.go"
click node_hash256 "https://github.com/kokinf/cryptocore/blob/main/src/hash/sha256.go"
click node_hash3 "https://github.com/kokinf/cryptocore/blob/main/src/hash/sha3.go"
click node_hmac "https://github.com/kokinf/cryptocore/blob/main/src/mac/hmac.go"
click node_random "https://github.com/kokinf/cryptocore/blob/main/src/csprng/csprng.go"
click node_deriveop "https://github.com/kokinf/cryptocore/blob/main/src/file_io.go"
click node_pbkdf2 "https://github.com/kokinf/cryptocore/blob/main/src/kdf/pbkdf2.go"
click node_hkdf "https://github.com/kokinf/cryptocore/blob/main/src/kdf/hkdf.go"

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_entry,node_parser,node_fileops,node_user toneBlue
class node_modes,node_cbc,node_ecb,node_othermodes,node_gcm,node_etm,node_random toneAmber
class node_hashop,node_hash256,node_hash3,node_hmac toneMint
class node_deriveop,node_pbkdf2,node_hkdf toneRose
class node_files toneIndigo
```

## Components

### Command line

- [Command entry](https://github.com/kokinf/cryptocore/blob/main/src/main.go): `src/main.go`
- [Argument parser](https://github.com/kokinf/cryptocore/blob/main/src/cli_parser.go): `src/cli_parser.go`
- [File operations](https://github.com/kokinf/cryptocore/blob/main/src/file_io.go): `src/file_io.go`

### Encryption

- [AES modes](https://github.com/kokinf/cryptocore/tree/main/src/modes): `src/modes`
- [CBC mode](https://github.com/kokinf/cryptocore/blob/main/src/modes/cbc.go): `src/modes/cbc.go`
- [ECB mode](https://github.com/kokinf/cryptocore/blob/main/src/modes/ecb.go): `src/modes/ecb.go`
- [CFB CTR OFB](https://github.com/kokinf/cryptocore/tree/main/src/modes): `src/modes`
- [GCM AEAD](https://github.com/kokinf/cryptocore/blob/main/src/aead/gcm.go): `src/aead/gcm.go`
- [Encrypt-then-MAC](https://github.com/kokinf/cryptocore/blob/main/src/aead/encrypt_then_mac.go): `src/aead/encrypt_then_mac.go`
- [Secure randomness](https://github.com/kokinf/cryptocore/blob/main/src/csprng/csprng.go): `src/csprng/csprng.go`

### Integrity

- [Hash operation](https://github.com/kokinf/cryptocore/blob/main/src/main.go): `src/main.go`
- [SHA-256](https://github.com/kokinf/cryptocore/blob/main/src/hash/sha256.go): `src/hash/sha256.go`
- [SHA3-256](https://github.com/kokinf/cryptocore/blob/main/src/hash/sha3.go): `src/hash/sha3.go`
- [HMAC](https://github.com/kokinf/cryptocore/blob/main/src/mac/hmac.go): `src/mac/hmac.go`

### Key derivation

- [Derive operation](https://github.com/kokinf/cryptocore/blob/main/src/file_io.go): `src/file_io.go`
- [PBKDF2](https://github.com/kokinf/cryptocore/blob/main/src/kdf/pbkdf2.go): `src/kdf/pbkdf2.go`
- [HKDF-style derivation](https://github.com/kokinf/cryptocore/blob/main/src/kdf/hkdf.go): `src/kdf/hkdf.go`

### Other components

- **CLI user**
- **Input/output files**

## Connections

- CLI user → Argument parser: provides flags (evidence: `README.md`)
- Command entry → Argument parser: parses arguments (evidence: `src/main.go`)
- Command entry → File operations: dispatches crypto (evidence: `src/main.go`)
- Command entry → Hash operation: dispatches hash (evidence: `src/main.go`)
- Command entry → Derive operation: dispatches derive (evidence: `src/main.go`)
- File operations → Input/output files: reads and writes (evidence: `README.md`)
- File operations → AES modes: processes AES files (evidence: `README.md`)
- File operations → GCM AEAD: uses AEAD (evidence: `README.md`)
- File operations → Encrypt-then-MAC: uses AEAD (evidence: `README.md`)
- AES modes → CBC mode: includes (evidence: `README.md`)
- AES modes → ECB mode: includes (evidence: `README.md`)
- AES modes → CFB CTR OFB: includes (evidence: `README.md`)
- GCM AEAD → Secure randomness: generates nonce (evidence: `src/aead/gcm.go`)
- Encrypt-then-MAC → AES modes: encrypts with (evidence: `src/aead/encrypt_then_mac.go`)
- Encrypt-then-MAC → HMAC: computes MAC (evidence: `src/aead/encrypt_then_mac.go`)
- Hash operation → Input/output files: hashes input (evidence: `README.md`)
- Hash operation → SHA-256: computes digest (evidence: `README.md`)
- Hash operation → SHA3-256: computes digest (evidence: `README.md`)
- Hash operation → HMAC: supports HMAC (evidence: `README.md`)
- HMAC → SHA-256: uses SHA-256 (evidence: `src/mac/hmac.go`)
- Derive operation → PBKDF2: derives key (evidence: `README.md`)
- Derive operation → HKDF-style derivation: offers key hierarchy (evidence: `README.md`)
- HKDF-style derivation → HMAC: computes blocks (evidence: `src/kdf/hkdf.go`)
- Derive operation → Secure randomness: generates salt (evidence: `README.md`)
