How to convert Data to hex string in swift

前端 未结 7 1950
走了就别回头了
走了就别回头了 2020-11-22 07:59

I want the hexadecimal representation of a Data value in Swift.

Eventually I\'d want to use it like this:

let data = Data(base64Encoded: \"aGVsbG8gd2         


        
7条回答
  •  孤街浪徒
    2020-11-22 08:31

    Maybe not the fastest, but data.map({ String($0, radix: 16) }).joined() does the job. As mentioned in the comments, this solution was flawed.

提交回复
热议问题