- CHANGELOG.md:v2.8.0 条目(中英双语); - README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明); - doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制); - skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/ require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过); - 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2.0 KiB
Executable File
markup, title, description
| markup | title | description |
|---|---|---|
| occlusion | lib/secrets | Cryptographic tokens (Mid M3). Do not use math.random for secrets. |
Cryptographic tokens. Do not use math.random for secrets.
Generate cryptographically random tokens.
Behavior and limits: n counts input bytes. Do not use math.random for credentials. Browser entropy depends on the runtime bridge; do not silently substitute a pseudo-random generator.
This single source file is the usage and development manual. Import it directly, or use marqdo call with a function heading below. Parameter tables give types and defaults; required parameters must be supplied. Return tables are progressive contracts; prose describes failure and limits.
Implementation: src/host/secrets.rs
For development, keep EN/ZH behavior aligned and compose public libraries first. Add host primitives only at OS or algorithm boundaries and declare their effects. Run marqdo check --narrative-ratio on this file and the real workflows in tests/stdlib_tasks.rs after edits.
token_hex
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| n | any | None | Requested byte count; None uses the helper default |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | text | Byte length n (default 16) |
Use n=None as the inputs for this operation.
Effects: random.read.
Call this function directly:
marqdo call lib/secrets.mq.md token_hex n=16 --effects random.read --json
Byte length n (default 16). Returns lowercase hex of length 2*n.
Caller: [secrets.token_hex] n=16
Return [Byte length n (default 16)](> host_secrets_token_hex n=n).
token_urlsafe
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
| n | any | None | Requested byte count; None uses the helper default |
| 返回 | 类型 | 说明 |
|---|---|---|
| result | text | Byte length n (default 16) |
Use n=None as the inputs for this operation.
Effects: random.read.
Byte length n (default 16). URL-safe Base64 without padding.
Return [Byte length n (default 16)](> host_secrets_token_urlsafe n=n).