Borg/php/borg-stmf/src/FormField.php
Snider b3755da69d feat: Add STMF form encryption and SMSG secure message packages
STMF (Sovereign Form Encryption):
- X25519 ECDH + ChaCha20-Poly1305 hybrid encryption
- Go library (pkg/stmf/) with encrypt/decrypt and HTTP middleware
- WASM module for client-side browser encryption
- JavaScript wrapper with TypeScript types (js/borg-stmf/)
- PHP library for server-side decryption (php/borg-stmf/)
- Full cross-platform interoperability (Go <-> PHP)

SMSG (Secure Message):
- Password-based ChaCha20-Poly1305 message encryption
- Support for attachments, metadata, and PKI reply keys
- WASM bindings for browser-based decryption

Demos:
- index.html: Form encryption demo with modern dark UI
- support-reply.html: Decrypt password-protected messages
- examples/smsg-reply/: CLI tool for creating encrypted replies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-27 00:49:07 +00:00

64 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Borg\STMF;
/**
* Represents a single form field
*/
class FormField
{
public string $name;
public string $value;
public ?string $type;
public ?string $filename;
public ?string $mimeType;
public function __construct(
string $name,
string $value,
?string $type = null,
?string $filename = null,
?string $mimeType = null
) {
$this->name = $name;
$this->value = $value;
$this->type = $type;
$this->filename = $filename;
$this->mimeType = $mimeType;
}
/**
* Check if this is a file field
*/
public function isFile(): bool
{
return $this->type === 'file';
}
/**
* Get the file content decoded from base64
*/
public function getFileContent(): ?string
{
if (!$this->isFile()) {
return null;
}
return base64_decode($this->value, true) ?: null;
}
/**
* Create from array
*/
public static function fromArray(array $data): self
{
return new self(
$data['name'] ?? '',
$data['value'] ?? '',
$data['type'] ?? null,
$data['filename'] ?? null,
$data['mime'] ?? null
);
}
}