Blocks

public struct Blocks

This structure represents padded plaintext. Blocks are acutally a byte array which is a multiple of a given block size.

  • The size of a single block in bytes.

    Declaration

    Swift

    public let blockSize: UInt32
  • The padded plaintext bytes.

    Declaration

    Swift

    public let bytes: Bytes
  • Constructs a Blocks instance from unpadded plaintext. This will add padding to the plaintext bytes.

    Postcondition

    blocks.bytes.count % blocks.blockSize = 0

    Declaration

    Swift

    public init?(unpadded: Bytes, blockSize: UInt32)

    Parameters

    unpadded

    The unpadded plaintext bytes.

    blockSize

    The size of a single block in bytes.

    Return Value

    nil if blockSize is 0.

  • Constructs a Blocks instance from padded plaintext.

    Declaration

    Swift

    public init?(padded: Bytes, blockSize: UInt32)

    Parameters

    padded

    The padded plaintext bytes.

    blockSize

    The size of a single block in bytes.

    Return Value

    nil if blockSize is 0 or if padded.count % blockSize ≠ 0

  • Return the plaintext without the padding.

    Declaration

    Swift

    public var withoutPadding: Bytes { get }