Structures

The following structures are available globally.

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

    See more

    Declaration

    Swift

    public struct Blocks
  • This class represents hashed passwords. They can be used to store passwords for the purpose of authenticating users. Passwords should not be stored as plaintext values to avoid compromise if they get in the wrong hands.

    Example

    let password = Password("Correct Horse Battery Staple")!
    let hashedPassword = password.hash()!
    
    // Store `hashedPassword.string` to database.
    
    // If a user wants to authenticate, just read it from the database and
    // verify it against the password given by the user.
    if hashedPassword.isVerified(by: password) {
        // The user is authenticated successfully.
    }
    
    See more

    Declaration

    Swift

    public struct HashedPassword
  • A wrapper for libsodium that on one hand offers convenient access to the libsodium bindings and on the other hand assures that libsodium was initialized before actually invoking methods.

    See more

    Declaration

    Swift

    struct Sodium