Skip to content
FutureBlitz

    Install

    Import std.crypto.random

    std.crypto.random

    SecureRandom, bytes and numbers from the OS's randomness, through mbedTLS's generator, for keys, salts, nonces, and tokens; and ConstantTimeEquals, which compares secrets without telling where they differ.

    std/crypto/random.fb

    Types

    SecureRandom struct

    Public Struct SecureRandom

    SecureRandom's Static Methods.

    std/crypto/random.fb, line 13

    • @PanicsAtCaller Public Static Method Bytes(count: Int): UInt8[] static method #

      count random bytes. Panics when count is negative.

    • @PanicsAtCaller Public Static Method Below(limit: Int64): Int64 static method #

      A random number from 0 up to limit, without limit, each as likely as another. Panics unless limit is above 0.

    Functions

    ConstantTimeEquals function

    Public Function ConstantTimeEquals(a: UInt8[], b: UInt8[]): Bool

    Whether a and b have the same bytes, in a time that depends only on their counts, not on where they first differ, so comparing a secret, like a MAC, tells nothing about it.

    std/crypto/random.fb, line 49

    Report an issue with this page or with FutureBlitz on GitHub.