Skip to content

Instantly share code, notes, and snippets.

@artemisia-absynthium
Created September 28, 2024 15:16
Show Gist options
  • Save artemisia-absynthium/b71a890824bd27c1510f6ffe6a446bd2 to your computer and use it in GitHub Desktop.
Save artemisia-absynthium/b71a890824bd27c1510f6ffe6a446bd2 to your computer and use it in GitHub Desktop.
Byte array pretty print
import Foundation
extension Data {
func toString() -> String {
if let string = String(data: self, encoding: .utf8) {
return string
} else {
return map { String(format: "%02X", $0) }.joined()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment