Skip to content

Class

BCryptDigest

Creates and verifies BCrypt hashes. Normally you will not need to initialize one of these classes and you will use the global BCrypt convenience instead.
final class BCryptDigest

Overview

try BCrypt.hash("vapor", cost: 4)

See BCrypt for more information.

Topics

Initializers

  • init()
    Creates a new BCryptDigest. Use the global BCrypt convenience variable.

Instance Methods

  • hash(_:cost:)
    Creates a new BCrypt hash with a randomly generated salt. The result can be stored in a database.
  • hash(_:salt:)
  • verify(_:created:)
    Verifies an existing BCrypt hash matches the supplied plaintext value. Verification works by parsing the salt and version from the existing digest and using that information to hash the plaintext data. If hash digests match, this method returns true.