9

I have been searching for a library, cocoapod, or something else that allows me to implement Bcrypt in iOS using Swift.

Bourne
  • 2,518
  • 1
  • 20
  • 27
  • Using an objective-c implementation with a bridging header in swift is one option. – Jack G. Aug 06 '15 at 12:01
  • You can check the link for bcrypt example("code.google.com/p/go.crypto/bcrypt"). It might be helpful. http://vluxe.io/swift-web-api.html [1]: http://vluxe.io/swift-web-api.html – Karlos Aug 06 '15 at 12:24
  • @Karlos are you sure that it can help anyhow? It's all about Go – Serge Velikan Dec 10 '15 at 18:38
  • @Bourne, I have found this https://github.com/dsibilly/bcrypt_objc, but I cannot get it to work… – Serge Velikan Dec 10 '15 at 18:39
  • @Serge Velikanov : Yes, It works fine in my project. If you want I can post a equivalent library or Objective C files in GitHub that can be used using Bridging-Header. But I can do that only on coming weekend. – Karlos Dec 11 '15 at 04:37
  • 1
    @Serge Velikanov : Please find the link for 5 files from which you can achieve bcrypt. You need to do objective-c implementation with a bridging header in swift. Hope this will be helpful. https://gist.github.com/Kadasiddha/6a4dd7e9301ee516c5db – Karlos Dec 11 '15 at 05:08
  • @Karlos, thank you for the answer. I've just used https://github.com/dsibilly/bcrypt_objc for my application and it is no problem. But my project is entirely in Objective C, didn't try this in Swift – Serge Velikan Dec 11 '15 at 08:23
  • 1
    If you are not locked into bcrypt consider PBKDF2 which is provided by Common Crypto. NIST is currently recommending PBKDF2 for hashing passwords for storage. – zaph Oct 18 '16 at 01:34

1 Answers1

5

BCryptSwift - cocoapod written in Swift.

There is also a cocoapod BCrypt, it's actually a version used in the Perfect (Swift-serverside toolkit), but adopted to be used in iOS as a cocoa pod dependency.

Sample usage:

import BCrypt

let password = "mypassword"
do {
    let salt = try BCrypt.Salt()
    let hashed = try BCrypt.Hash(password, salt: salt)
    print("Hashed result is: \(hashed)")
}
catch {
    print("An error occured: \(error)")
}
beryllium
  • 29,669
  • 15
  • 106
  • 125