Skip to content

Type Method

hash(_:cost:)

Creates a new bcrypt hash with a randomly generated salt. The result can be stored in a database. parameters: - plaintext: Plaintext data to hash. - cost: Desired complexity. Larger cost values take longer to hash and verify. Default is 12.
static func hash(_ plaintext: String, cost: Int = 12) throws(BcryptError) -> String

Return Value

Newly created bcrypt hash.

Discussion

Throws

BcryptError if hashing fails or if data conversion fails.