We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent baaec2a commit a4951b2Copy full SHA for a4951b2
1 file changed
ios/RCTCrypto/lib/Shared.m
@@ -7,10 +7,13 @@
7
@implementation Shared
8
9
+ (NSString *) toHex:(NSData *)nsdata {
10
- NSString * hexStr = [NSString stringWithFormat:@"%@", nsdata];
11
- for(NSString * toRemove in [NSArray arrayWithObjects:@"<", @">", @" ", nil])
12
- hexStr = [hexStr stringByReplacingOccurrencesOfString:toRemove withString:@""];
13
- return hexStr;
+ // Copied from: https://riptutorial.com/ios/example/18979/converting-nsdata-to-hex-string
+ const unsigned char *bytes = (const unsigned char *)nsdata.bytes;
+ NSMutableString *hex = [NSMutableString new];
+ for (NSInteger i = 0; i < nsdata.length; i++) {
14
+ [hex appendFormat:@"%02x", bytes[i]];
15
+ }
16
+ return [hex copy];
17
}
18
19
+ (NSData *) fromHex: (NSString *)string {
0 commit comments