I have a string of data that I want to encrypt in AES 128 and the encrypted data should be in binary. I have tried using CryptoSwith to do so. But the issue I am getting is that the encryption code that I found from an online help converts in into HexString. I tried looking for the conversion to binary but couldn't find a working solution. The code I am using is below :
func encrypt(data: String) -> String? {
if let aes = try? AES(key: "0101010101010101", iv: "0000000000000000"),
let encrypted = try? aes.encrypt(Array(data.utf8)) {
return encrypted.toHexString()
}
return
}
Would really appreciate the help.