Nonce

public class Nonce : KeyMaterial

This class represents a nonce (number used once) that is required for indeterministically encrypting a given message.

  • The size of the nonce in bytes.

    Declaration

    Swift

    public static let SizeInBytes: UInt32
  • Creates a new random nonce.

    Declaration

    Swift

    public init()
  • Restores a nonce from a byte array. The byte array is copied to a secure location and overwritten with zeroes to avoid the nonce being compromised in memory. The nonce itself is not a secret value, but access in other contexts is not necessary.

    Warning

    Do not use this function to create nonces. This initializer is only intended to restore a nonce that was persisted.

    Declaration

    Swift

    public override init?(bytes: inout Bytes)

    Parameters

    bytes

    The nonce.

  • Compares two nonces in constant time.

    Declaration

    Swift

    public static func == (lhs: SecretBox.Nonce, rhs: SecretBox.Nonce) -> Bool

    Parameters

    lhs

    A nonce.

    rhs

    Another nonce.

    Return Value

    true if both nonces are equal.