summaryrefslogtreecommitdiff
path: root/Juick/Helpers/NSData+Hex.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/Helpers/NSData+Hex.m')
-rw-r--r--Juick/Helpers/NSData+Hex.m22
1 files changed, 22 insertions, 0 deletions
diff --git a/Juick/Helpers/NSData+Hex.m b/Juick/Helpers/NSData+Hex.m
new file mode 100644
index 0000000..243a380
--- /dev/null
+++ b/Juick/Helpers/NSData+Hex.m
@@ -0,0 +1,22 @@
+//
+// NSData+Hex.m
+// Juick
+//
+// Created by Vitaly Takmazov on 01/10/2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+#import "NSData+Hex.h"
+
+@implementation NSData (Hex)
+- (NSString *)hexString {
+ NSMutableString *string = [NSMutableString stringWithCapacity:self.length * 3];
+ [self enumerateByteRangesUsingBlock:^(const void *bytes, NSRange byteRange, BOOL *stop){
+ for (NSUInteger offset = 0; offset < byteRange.length; ++offset) {
+ uint8_t byte = ((const uint8_t *)bytes)[offset];
+ [string appendFormat:@"%02x", byte];
+ }
+ }];
+ return string;
+}
+@end