Skip to content

Commit 2e216c2

Browse files
authored
Merge pull request #29 from plouh/patch-1
Fix toHex to work on iOS 13
2 parents f0a2a2a + 339e6a1 commit 2e216c2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ios/RCTAes/lib/AesCrypt.m

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
@implementation AesCrypt
1515

1616
+ (NSString *) toHex:(NSData *)nsdata {
17-
NSString * hexStr = [NSString stringWithFormat:@"%@", nsdata];
18-
for(NSString * toRemove in [NSArray arrayWithObjects:@"<", @">", @" ", nil])
19-
hexStr = [hexStr stringByReplacingOccurrencesOfString:toRemove withString:@""];
20-
return hexStr;
17+
const unsigned char *bytes = (const unsigned char *)nsdata.bytes;
18+
NSMutableString *hex = [NSMutableString new];
19+
for (NSInteger i = 0; i < nsdata.length; i++) {
20+
[hex appendFormat:@"%02x", bytes[i]];
21+
}
22+
return [hex copy];
2123
}
2224

2325
+ (NSData *) fromHex: (NSString *)string {

0 commit comments

Comments
 (0)