extension NSData { func hexString() -> String { return UnsafeBufferPointer<UInt8>(start: UnsafePointer<UInt8>(bytes), count: length) .reduce("") { $0 + String(format: "%02x", $1) } } }