- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在使用 Cross-Platform-AES用于我的 swift 应用程序中的 AES 加密/解密。我的加密工作正常。但是当我尝试解密服务返回值时,它没有给我正确的结果。这是我解密的方式。
public func decryptStrings(text:String)->String{
let hashKey=cryptoLib.sha256(key, length: 31)
let decryptedData = cryptoLib.decrypt(text.data(using: String.Encoding.utf8), key: hashKey, iv: iv)
let decryptedString=decryptedData?.base64EncodedString()
print("decryptedString \(decryptedString! as String)")
return decryptedString!
}
请向我解释如何以正确的方式解密它。谢谢
加密
public func base64Convertion (secretcode:String)->String
{
let hashKey=cryptoLib.sha256(key, length: 31)
let encryptedData=cryptoLib.encrypt(secretcode.data(using: String.Encoding.utf8), key: hashKey, iv: iv)
let encryptedString=encryptedData?.base64EncodedString()
print("encryptedString \(encryptedString! as String)")
return encryptedString!
}
最佳答案
我通过这种方式更改解密方法解决了问题
public func decryptStrings(text:String)->String{
let hashKey=cryptoLib.sha256(key, length: 31)
let decodedData = Data(base64Encoded: text, options: Data.Base64DecodingOptions())
let decryptedData = cryptoLib.decrypt(decodedData, key: hashKey, iv: iv)
let decryptedString=String(data: decryptedData!,encoding:String.Encoding.utf8)
print("decryptedString \(decryptedString!)")
return decryptedString!
}
关于swift - CryptLib 解密返回错误值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44258550/
你好。 首先:我是 stackOverflow 和我正在谈论的主题的新手...... 我试图避免使用 cryptlib我的 Java 应用程序中用于 TripleDES 加密的库(现在我使用 AES
我正在尝试转换Crypt Lib in js的逻辑,我有现有的android应用程序,并且该API位于c Sharp中,我想转换加密和解密逻辑。 我尝试了多种版本,您可以检查代码:Tried code
我正在使用 Cross-Platform-AES用于我的 swift 应用程序中的 AES 加密/解密。我的加密工作正常。但是当我尝试解密服务返回值时,它没有给我正确的结果。这是我解密的方式。 pub
我实际上是在编程和端到端加密日历。为此,我使用 cryptlib .我或多或少复制了 manual 中的代码.但总是,当我尝试生成根 ca 时。它在 cryptSignCert() 处失败,错误代码为
我已经从官方网站下载了 Crypto++ 7.0.0,用它构建了一个静态库,包括 cryptlib 头文件: #include "cryptlib.h" 当我尝试编译我的程序时: gcc main.c
我的应用程序使用 AES 256 加密来加密字符串。之前使用的相同代码会生成不同的结果。这个问题在 iOS 13 发布时就开始出现。这种情况仅发生在发布到商店或使用 Xcode 11 构建的应用程序中
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
在Visual Studio上编译项目时,出现上述错误。我的情况有一个奇怪的地方,与众不同的是,它可以在我的个人笔记本电脑上工作,但不能工作。 我将整个项目保存在Dropbox中,因为有时我会在工作状
编辑:好的,我解决了我最初概述的无法找到 curl 和 cryptlib header 的问题。但是,在通过使用 macports 安装 curl 和 libcryptopp 解决了这些问题之后,我在
我是一名优秀的程序员,十分优秀!