diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 0c9ce7c..5ad0dc3 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -14,5 +14,3 @@ jobs: contents: read pages: write id-token: write - with: - docc_swift_version: "6.2" diff --git a/README.md b/README.md index c43543d..43864c8 100644 --- a/README.md +++ b/README.md @@ -40,13 +40,7 @@ Update the packages and you are ready. ![DocC API documentation](https://img.shields.io/badge/DocC-API_documentation-F05138) -API documentation is available at the following [link] (https://binarybirds.github.io/bcrypt). Refer to the mock objects in the Tests directory if you want to build a custom database driver implementation. - -> [!TIP] -> Avoid calling `database.execute` while in a transaction; use the transaction `connection` instead. - -> [!WARNING] -> This repository is a work in progress, things can break until it reaches v1.0.0. +API documentation is available at the following [link](https://binarybirds.github.io/swift-bcrypt). Refer to the mock objects in the Tests directory if you want to build a custom database driver implementation. ## Usage example diff --git a/Sources/BCrypt/BCrypt.swift b/Sources/BCrypt/BCrypt.swift index 1770026..a4ef28d 100644 --- a/Sources/BCrypt/BCrypt.swift +++ b/Sources/BCrypt/BCrypt.swift @@ -55,7 +55,7 @@ public final class BCrypt { /// or ``BCryptError/hashFailure`` if hashing fails. /// - Returns: A BCrypt hash string suitable for storage (e.g. in a database). public func hash( - _ plaintext: String, + _ plaintext: String, cost: Int = 12 ) throws(BCryptError) -> String { guard cost >= BCRYPT_MINLOGROUNDS && cost <= 31 else { @@ -80,7 +80,7 @@ public final class BCrypt { /// or ``BCryptError/hashFailure`` if hashing fails. /// - Returns: A BCrypt hash string. public func hash( - _ plaintext: String, + _ plaintext: String, salt: String ) throws(BCryptError) -> String { guard isSaltValid(salt) else { @@ -150,7 +150,7 @@ public final class BCrypt { /// or ``BcryptError/hashFailure`` if hashing fails during verification. /// - Returns: `true` if `plaintext` matches the hash; otherwise `false`. public func verify( - _ plaintext: String, + _ plaintext: String, created hash: String ) throws(BCryptError) -> Bool { guard let hashVersion = Algorithm(rawValue: String(hash.prefix(4))) @@ -196,18 +196,12 @@ public final class BCrypt { /// - algorithm: The BCrypt revision to use (defaults to `$2b$`). /// - seed: Optional raw salt bytes. If `nil`, random bytes are generated. Must be 16 bytes when provided. /// - Returns: A full salt string suitable to pass to ``hash(_:salt:)``. - private func generateSalt( - cost: Int, - algorithm: Algorithm = .b, - seed: [UInt8]? = nil - ) - -> String - { private func generateSalt( cost: Int, algorithm: Algorithm = .b, seed: [UInt8]? = nil ) -> String { + let randomData: [UInt8] if let seed = seed { randomData = seed }