libhardcopy 1.0.1

Generalized library for hardcopy/softcopy command line utilities.
Documentation
# libhardcopy

Current Release: 1.0.1

[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![builds.sr.ht status](https://builds.sr.ht/~dstar4138/hardcopy.svg)](https://sr.ht/~dstar4138/hardcopy)
[![Latest version](https://img.shields.io/crates/v/libhardcopy.svg)](https://crates.io/crates/libhardcopy)
[![Documentation](https://docs.rs/libhardcopy/badge.svg)](https://docs.rs/libhardcopy)

Core library for hardcopy/softcopy encoding. Provides plugins for encoding binary data into printable formats (mnemonics, QR codes) and decoding them back.

## Features

- **Plugin architecture**: Extensible encoding/decoding plugins
- **Multiple output formats**: Word lists, QR codes (PNG bytes)
- **Round-trip encoding**: Generate hard copy, recover soft copy, validate integrity
- **Checksums**: Built-in SHA-256 verification

## Plugins

| Feature | Plugin | Encoding | Words/Line | Description |
|---------|--------|----------|------------|-------------|
| `out-qrcode` | `qrcode` | Binary → QR PNG | N/A | QR codes (500 bytes/code) |
| `out-bip39` | `bip39` | Binary → BIP-39 words | 6 | 2048-word mnemonic list |
| `out-diceware` | `diceware` | Binary → EFF Diceware | 6 | 7776-word EFF list (12 bits/word) |
| — | `pgpfone` | Binary → PGPfone words | 4 | Phonetically distinct words |
| — | `skeyotp` | Binary → S/KEY OTP words | 6 | RFC 2289 one-time passwords |

Default features: none. Enable with Cargo features.

## Data Structures

```rust
use libhardcopy::{HardCopy, HardCopySection, SoftCopyInput, SoftCopy};

// Input: binary data to encode
let input = SoftCopyInput::from_bytes(vec![0x01, 0x02, 0x03]);

// Generate hard copy using a plugin
let plugin = libhardcopy::plugins::pgpfone::PGPfonePlugin;
let hardcopy = plugin.generate_hard_copy(&input)?;

// Render sections (words or QR PNG bytes)
for section in &hardcopy.sections {
    match &section.content {
        HardCopySectionContent::Words(lines) => {
            for line in lines { println!("{}", line); }
        }
        HardCopySectionContent::Bytes(png) => {
            std::fs::write("qrcode.png", png)?;
        }
    }
}

// Recover soft copy from user-entered words
let mut user_input = libhardcopy::HardCopyInput::new();
user_input.push_line("0001: ALPHA BRAVO CHARLIE DELTA");
let softcopy = plugin.generate_soft_copy(&mut user_input)?;
let recovered_bytes = softcopy.bytes;
```

## Plugin Traits

```rust
pub trait LibPlugin {
    fn name(&self) -> String;
    fn description(&self) -> String;
    fn instructions(&self) -> String;  // User-facing recovery instructions
}

pub trait HardCopyGenerator {
    fn generate_hard_copy(&self, input: &SoftCopyInput) -> Result<HardCopy>;
}

pub trait SoftCopyGenerator {
    fn generate_soft_copy(&self, input: &mut HardCopyInput) -> Result<SoftCopy>;
}

pub trait SoftCopyValidator {
    fn validate_soft_copy(&self, softcopy: &SoftCopyInput) -> Result<()>;
    fn validate_hard_copy_input(&self, input: &HardCopyInput) -> Result<()>;
}
```

## Cargo Features

```toml
[dependencies]
libhardcopy = { version = "1.0.0", features = ["out-qrcode", "out-bip39", "out-diceware"] }

[features]
out-qrcode   = ["qrcode", "image"]
out-bip39    = ["wordlists/bip-39"]
out-diceware = ["wordlists/diceware-eff-large"]
```

## Usage in hardcopy/softcopy CLI

This library powers the `hardcopy` (encode) and `softcopy` (decode) binaries in this workspace.

- `hardcopy` — reads stdin/files, encodes via plugins, outputs PDF/TXT/HTML
- `softcopy` — interactive decode from word lists, validates checksums

## License

GPL-3.0