微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么CryptoSwift中的IV =“”加密在Swift5上不起作用?

如何解决为什么CryptoSwift中的IV =“”加密在Swift5上不起作用?

尝试加密密码时出现错误。我找不到为什么encryption(iv = "")在swift 3上可以正常工作,但现在在iv = ""在swift 5上不能正常工作的原因。我该如何解决呢?

userText = userText.replacingOccurrences(of: "\\s+",with: "",options: .regularExpression,range: nil)
let request:NSMutableuRLRequest!
let capcha:String! = ""
let encryptedBase64Password = try! passtext.encrypt(cipher: AES(key: encrypKeyForLogin,iv: ""))
Fatal error: 'try!' expression unexpectedly raised an error: CryptoSwift.CBC.Error.invalidInitializationVector: file /Users/vietnguyen/Documents/Mac os/Code/Swift5/SlideOutMenu/SlideOutMenu/Login/LoginServer.swift,line 97 
2020-09-17 21:48:13.326595+0700 SlideOutMenu[2104:103521] Fatal error: 'try!' expression unexpectedly raised an error: CryptoSwift.CBC.Error.invalidInitializationVector: file /Users/vietnguyen/Documents/Mac os/Code/Swift 5/SlideOutMenu/SlideOutMenu/Login/LoginServer.swift,line 97

Line 97: let encryptedBase64Password = try! passtext.encrypt(cipher: AES(key: encrypKeyForLogin,iv: ""))

我很困惑,因为在swift 5 iv中有16byte可用,但是在swift 3 iv =“”之前工作正常。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。