fittings-crypto-random-bytes

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Cryptographically secure random bytes

加密安全随机字节

crypto.random-bytes
on
https://fittings.sh
. One endpoint, deterministic compute.
Generate CSPRNG bytes from the Web Crypto API, returned as hex, base64 or a UUID. Never Math.random.
crypto.random-bytes
服务位于
https://fittings.sh
。单端点,确定性计算。
通过Web Crypto API生成CSPRNG字节,返回格式为hex、base64或UUID。绝不使用Math.random。

The call

调用方式

GET https://fittings.sh/v1/crypto/random-bytes
FieldTypeRequiredNotes
bytes
numberno1-1024
encoding
stringnohex | base64 | uuid
Example input:
json
{
  "bytes": 32,
  "encoding": "hex"
}
GET https://fittings.sh/v1/crypto/random-bytes
字段类型是否必填说明
bytes
数字1-1024
encoding
字符串hex | base64 | uuid
示例输入:
json
{
  "bytes": 32,
  "encoding": "hex"
}

Metered

计量计费

The 402 quotes a ceiling — the price of the declared cap, 1024 bytes — and settlement is for what the call actually used. A small request settles for less than it was quoted, so read the quote as an upper bound rather than a price.
402响应会给出一个上限报价——即声明的最大容量(1024字节)对应的价格——而最终结算则按实际调用使用的字节数计算。小请求的结算费用会低于报价,因此可将报价视为最高限价而非固定价格。

Cost and provenance

费用与来源

Price$0.003 per call, metered per bytes
Sourcenone (pure compute)
Licencenone-needed
价格每次调用0.003美元,按字节数计量
来源无(纯计算服务)
许可证无需许可证

Why call it rather than answer from memory

为何调用该服务而非本地生成

Observed on-chain demand: agents need unguessable nonces, tokens and idempotency keys, and a language runtime without a CSPRNG or a model asked to "pick a random number" both produce predictable output.
链上需求观察:Agent需要不可预测的nonce、令牌和幂等键,而没有CSPRNG的语言运行时或被要求“随机选一个数”的模型都会产生可预测的输出。

Calling it

调用方法

A skill is loaded on its own, so this document has to be enough by itself. It does not assume the general
fittings
skill is also loaded.
call.mjs
ships alongside this file; if it is missing (this document reached you without the rest of the skill), fetch it once with
curl -sO https://fittings.sh/skill/call.mjs
.
Free, and needs no wallet. Read the schema and see what a call would cost:
bash
curl -s https://fittings.sh/catalog/crypto.random-bytes | jq
Paying. The endpoint answers
402 Payment Required
with a signed quote, you sign an authorization, and a facilitator settles it — you never send a transaction and never pay gas. Before it spends anything, the client checks its own hash against the gateway and refuses rather than sign with logic the gateway has moved past:
bash
undefined
该Skill可独立加载,因此本文档本身已足够使用,无需假设已加载通用的
fittings
Skill。
call.mjs
文件与本文档一同提供;如果缺失(本文档未随Skill其余部分送达),可通过
curl -sO https://fittings.sh/skill/call.mjs
获取一次。
免费调用,无需钱包。 查看接口schema并了解调用费用:
bash
curl -s https://fittings.sh/catalog/crypto.random-bytes | jq
付费调用。 端点会返回
402 Payment Required
响应及签名报价,您需签署授权,由服务商完成结算——您无需发送交易,也无需支付gas费。在产生任何费用前,客户端会将自身哈希与网关进行比对,若网关逻辑已更新则会拒绝签署:
bash
undefined

Dry run. Prints the quote and pays nothing, because no key is set.

预演。仅打印报价,无需支付费用,因为未设置密钥。

node call.mjs crypto.random-bytes bytes=32 encoding=hex
node call.mjs crypto.random-bytes bytes=32 encoding=hex

For real: a wallet holding USDC on Base, and nothing else.

实际调用:使用Base链上持有USDC的钱包,无需其他资产。

export FITTINGS_PRIVATE_KEY=0x... node call.mjs crypto.random-bytes bytes=32 encoding=hex

Spending is never a side effect of curiosity: with no `FITTINGS_PRIVATE_KEY`
the client fetches the quote and stops. `FITTINGS_MAX_PRICE` caps what it will
pay without asking, and defaults to $0.05.

**Use a throwaway wallet holding a few dollars, not a main one.** The key sits
in plaintext wherever the agent runs, and the whole cost of entry is USDC on
Base — no account, no API key, and no ETH, because the payer signs off-chain and
the facilitator broadcasts and pays the gas.

Writing your own client instead of using this one? `@x402/core` and
`@x402/evm` on npm, and the `fittings` skill records the two things that cost
real debugging time: the challenge is in a response header rather than the body,
and it must be re-signed from the exact request being retried.

If this is not the right service, `https://fittings.sh/catalog/search?q=...`
searches all of them for free.
export FITTINGS_PRIVATE_KEY=0x... node call.mjs crypto.random-bytes bytes=32 encoding=hex

探索性操作绝不会产生消费:未设置`FITTINGS_PRIVATE_KEY`时,客户端仅获取报价后即停止。`FITTINGS_MAX_PRICE`可设置无需确认的最高支付限额,默认值为0.05美元。

**请使用仅持有少量资金的临时钱包,勿使用主钱包。** 密钥以明文形式存储在Agent运行的环境中,入门成本仅为Base链上的USDC——无需账户、无需API密钥、无需ETH,因为付款方进行链下签名,由服务商广播交易并支付gas费。

不想使用该客户端,希望自行编写?可使用npm上的`@x402/core`和`@x402/evm`,`fittings` Skill记录了两个耗时较多的调试要点:挑战信息位于响应头而非响应体中,且必须针对重试的精确请求重新签名。

如果该服务不符合您的需求,可通过`https://fittings.sh/catalog/search?q=...`免费搜索所有服务。