1
我有一些.net代码生成哈希密钥加密,我想在iOS中的代码,但我找不到合适的解决方案,如果任何人有合适的解决方案,请帮助我如何通过IOS中的预定义短语和salt值生成散列键?
我添加我的.net代码,它工作正常,我想在iOS设备上的代码转换具有相同的结果
Public Shared Function Encrypt(ByVal plainText As String) As String
Dim passPhrase As String = "passPhrase"
Dim saltValue As String = "saltValue"
Dim hashAlgorithm As String = "SHA256"
Dim passwordIterations As Integer = 2
Dim initVector As String = "abc123def456gh78"
Dim keySize As Integer = 256
Dim initVectorBytes As Byte() = Encoding.ASCII.GetBytes(initVector)
Dim saltValueBytes As Byte() = Encoding.ASCII.GetBytes(saltValue)
Dim plainTextBytes As Byte() = Encoding.UTF8.GetBytes(plainText)
Dim password As New PasswordDeriveBytes(passPhrase, saltValueBytes, hashAlgorithm, passwordIterations)
Dim keyBytes As Byte() = password.GetBytes(keySize \ 8)
End Function
你可以使用SHA256 – Paulw11
@ Paulw11是的,FBEncryptorAES加密类CommonCrypto框架 –