diff --git a/SwiftyIroha/ObjC++/ModelCrypto/IRModelCrypto.mm b/SwiftyIroha/ObjC++/ModelCrypto/IRModelCrypto.mm index f7d1d8f61..a1dcaf295 100644 --- a/SwiftyIroha/ObjC++/ModelCrypto/IRModelCrypto.mm +++ b/SwiftyIroha/ObjC++/ModelCrypto/IRModelCrypto.mm @@ -133,11 +133,6 @@ - (KeypairObjC*) generateFromExistingKeypair:(IRKeypair*) keypair { -(string)getStringCppWithString:(NSString*)stringObjC { string stringCpp = string([stringObjC UTF8String], [stringObjC lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); - cout << stringCpp; - cout << "\n"; - cout << stringCpp.length(); - cout << "\n"; - cout << "\n"; return stringCpp; } diff --git a/SwiftyIroha/ObjC++/ModelTransactionBuilder/IRModelTransactionBuilder.mm b/SwiftyIroha/ObjC++/ModelTransactionBuilder/IRModelTransactionBuilder.mm index 3b60518bf..1893d3562 100644 --- a/SwiftyIroha/ObjC++/ModelTransactionBuilder/IRModelTransactionBuilder.mm +++ b/SwiftyIroha/ObjC++/ModelTransactionBuilder/IRModelTransactionBuilder.mm @@ -288,23 +288,18 @@ -(string)getStringCppFromStringObjC:(NSString*)stringObjC { } - (NSData *)dataFromHexString:(NSString *) string { - if ([string length] % 2 == 1){ - string = [@"0" stringByAppendingString:string]; + [string stringByReplacingOccurrencesOfString:@" " withString:@""]; + NSMutableData* dataValue = [[NSMutableData alloc] init]; + unsigned char byte; + char byte_chars[3] = {'\0','\0','\0'}; + int i; + for (i=0; i < [string length]/2; i++) { + byte_chars[0] = [string characterAtIndex:i*2]; + byte_chars[1] = [string characterAtIndex:i*2+1]; + byte = strtol(byte_chars, NULL, 16); + [dataValue appendBytes:&byte length:1]; } - const char *chars = [string UTF8String]; - int i = 0, len = (int)[string length]; - - NSMutableData *data = [NSMutableData dataWithCapacity:len / 2]; - char byteChars[3] = {'\0','\0','\0'}; - unsigned long wholeByte; - - while (i < len) { - byteChars[0] = chars[i++]; - byteChars[1] = chars[i++]; - wholeByte = strtoul(byteChars, NULL, 16); - [data appendBytes:&wholeByte length:1]; - } - return data; + return dataValue; } @end