summaryrefslogtreecommitdiff
path: root/Juick/Helpers
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-10-01 17:29:46 +0300
committerGravatar Vitaly Takmazov2019-10-01 22:14:59 +0300
commitdbab6ab54c40a016f75e75a4143576c3fa41c3e0 (patch)
tree6fd5e68ec76c249fcaa07219c53ccab2f4c98fd5 /Juick/Helpers
parentaeb513ed5c165e355c9c378efde7445f597d0380 (diff)
Drop AFNetworking and SSKeychain
Diffstat (limited to 'Juick/Helpers')
-rw-r--r--Juick/Helpers/NSData+Hex.h19
-rw-r--r--Juick/Helpers/NSData+Hex.m22
2 files changed, 41 insertions, 0 deletions
diff --git a/Juick/Helpers/NSData+Hex.h b/Juick/Helpers/NSData+Hex.h
new file mode 100644
index 0000000..bd8e519
--- /dev/null
+++ b/Juick/Helpers/NSData+Hex.h
@@ -0,0 +1,19 @@
+//
+// NSData+Hex.h
+// Juick
+//
+// Created by Vitaly Takmazov on 01/10/2019.
+// Copyright © 2019 com.juick. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface NSData (Hex)
+
+- (NSString *)hexString;
+
+@end
+
+NS_ASSUME_NONNULL_END
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