Last active
July 14, 2018 12:44
-
-
Save kristopherjohnson/ed2623e1b486a8262b12 to your computer and use it in GitHub Desktop.
Revisions
-
kristopherjohnson revised this gist
Oct 24, 2014 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,11 +9,10 @@ extension NSData { getBytes(&bytes, length: length) let hexString = NSMutableString() for byte in bytes { hexString.appendFormat("%02x", UInt(byte)) } return NSString(string: hexString) } } -
kristopherjohnson revised this gist
Oct 23, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ extension NSData { var bytes = [UInt8](count: length, repeatedValue: 0) getBytes(&bytes, length: length) let hexString = NSMutableString() for i in 0..<length { let byte = bytes[i] hexString.appendFormat("%02x", UInt(byte)) -
kristopherjohnson revised this gist
Oct 23, 2014 . 1 changed file with 4 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,19 +5,15 @@ extension NSData { /// Return hexadecimal string representation of NSData bytes @objc(kdj_hexadecimalString) public var hexadecimalString: NSString { var bytes = [UInt8](count: length, repeatedValue: 0) getBytes(&bytes, length: length) var hexString = NSMutableString() for i in 0..<length { let byte = bytes[i] hexString.appendFormat("%02x", UInt(byte)) } return NSString(string: hexString) } } -
kristopherjohnson created this gist
Oct 23, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ import Foundation extension NSData { /// Return hexadecimal string representation of NSData bytes @objc(kdj_hexadecimalString) public var hexadecimalString: NSString { let buffer = malloc(UInt(length)) getBytes(buffer, length: length) let byteArray = UnsafePointer<UInt8>(buffer) var hexString: NSMutableString = NSMutableString() for i in 0..<length { let byte: UInt8 = byteArray[i] hexString.appendFormat("%02x", UInt(byte)) } free(buffer) return NSString(string: hexString) } }