【问题标题】:Is there a way to utilize Bcrypt for iOS development with Swift?有没有办法通过 Swift 将 Bcrypt 用于 iOS 开发?
【发布时间】:2015-10-29 13:29:42
【问题描述】:

我一直在寻找可以让我使用 Swift 在 iOS 中实现 Bcrypt 的库、cocoapod 或其他东西。

【问题讨论】:

  • 在swift中使用带有桥接头的objective-c实现是一种选择。
  • 您可以查看 bcrypt 示例的链接(“code.google.com/p/go.crypto/bcrypt”)。这可能会有所帮助。 vluxe.io/swift-web-api.html[1]:vluxe.io/swift-web-api.html
  • @Karlos 你确定它无论如何都能提供帮助吗?一切都是关于围棋
  • @Serge Velikanov:请找到 5 个文件的链接,您可以从中实现 bcrypt。您需要在 swift 中使用桥接头进行 Objective-C 实现。希望这会有所帮助。 gist.github.com/Kadasiddha/6a4dd7e9301ee516c5db
  • 如果您没有被锁定在 bcrypt 中,请考虑使用 Common Crypto 提供的 PBKDF2。 NIST 目前推荐 PBKDF2 用于存储密码的散列。

标签: ios swift hash passwords bcrypt


【解决方案1】:

BCryptSwift - 用 Swift 编写的 cocoapod。

还有一个 cocoapod BCrypt,它实际上是 Perfect(Swift-serverside 工具包)中使用的一个版本,但在 iOS 中被采用作为 cocoa pod 依赖项。

示例用法:

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)")
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-16
    相关资源
    最近更新 更多