Convert an ASCII Array to String Swift 4

0

I'm doing an app in swift 4 of encrypted and decrypted, the question starts here. when DESENCRIPT returns an Array with the values in ASCII Array

  

[109, 105, 32, 109, 101, 110, 115, 97, 106, 101, 32, 111, 99, 117, 108, 116, 111] // Encrypted String - > "my hidden message".

Does anyone know how I can convert the ASCII Array into the message I need?

    
asked by Judá Escalera 21.08.2018 в 21:24
source

1 answer

0

This way you can convert a UInt8 type array to a string

 let cadenaEncriptada: [UInt8] = [109, 105, 32, 109, 101, 110, 115, 97, 106, 101, 32, 111, 99, 117, 108, 116, 111]
 if let valor = String(bytes: cadenaEncriptada, encoding: .utf8) {
     print(valor)
 }
    
answered by 22.08.2018 в 00:12