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框架 –