https://github.com/binarybirds/swift-bcrypt
Swift BCrypt implementation for securely hashing and verifying passwords using adaptive cost factors, random salts, and constant-time comparison.
https://github.com/binarybirds/swift-bcrypt
Last synced: about 1 month ago
JSON representation
Swift BCrypt implementation for securely hashing and verifying passwords using adaptive cost factors, random salts, and constant-time comparison.
- Host: GitHub
- URL: https://github.com/binarybirds/swift-bcrypt
- Owner: BinaryBirds
- License: mit
- Created: 2024-02-06T14:58:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-02-11T08:10:24.000Z (4 months ago)
- Last Synced: 2026-02-11T15:20:58.391Z (4 months ago)
- Language: C
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Swift BCrypt
Swift BCrypt implementation for securely hashing and verifying passwords using
adaptive cost factors, random salts, and constant-time comparison.
[]( https://github.com/binarybirds/swift-bcrypt/releases/tag/2.0.1)
## Requirements


- Swift 6.1+
- Platforms:
- macOS 15+
- iOS 18+
- tvOS 18+
- watchOS 11+
- visionOS 2+
## Installation
Use Swift Package Manager; add the dependency to your `Package.swift` file:
```swift
.package(url: "https://github.com/binarybirds/swift-bcrypt", exact: "2.0.1"),
```
Then add `Bcrypt` to your target dependencies:
```swift
.product(name: "Bcrypt", package: "swift-bcrypt"),
```
Update the packages and you are ready.
## Usage
[](https://binarybirds.github.io/swift-bcrypt)
API documentation is available at the following link. Refer to the mock objects in the Tests directory if you want to build a custom database driver implementation.
## Usage example
```swift
import Bcrypt
let digest = try Bcrypt.hash("binary-birds", cost: 6)
let res = try Bcrypt.verify("binary-birds", created: digest)
```
## Development
- Build: `swift build`
- Test:
- local: `swift test`
- using Docker: `make docker-test`
- Format: `make format`
- Check: `make check`
## Contributing
[Pull requests](https://github.com/binarybirds/swift-bcrypt/pulls) are welcome. Please keep changes focused and include tests for new logic.
## Credits
This code is derived from the Vapor web framework:
- [Vapor](https://github.com/vapor/vapor)