本文へ移動
Hikari リファレンス

std:crypto/random リファレンス

import crand := "std:crypto/random" で取得する暗号用乱数モジュール。bytes(n) がホストのエントロピー源から n バイトを Result で返す (源の無い環境では Err)。

bytes

bytes(n)
bytes: { Int | Effect(Result(Bytes), Rand) }

ホストのエントロピー源から n バイトを取得する (Result。n が 0 なら空)。

>>> import crand := "std:crypto/random"
>>> (crand.bytes 0).unwrap!