简体   繁体   English

IOS 加密与上面 Xcode11 不同

[英]IOS encryption different in Xcode11 above

Before xcode11, the encryption get for both ios12 below and ios13 above is the same.在xcode11之前,下面ios12和上面ios13的加密get是一样的。

But after upgrade to xcode11, the encryption in ios12 below is still the same.但是升级到xcode11后,下面ios12中的加密还是一样。 But in Ios13 above, the encryption string i get include "length" and "bytes".但是在上面的 Ios13 中,我得到的加密字符串包括“长度”和“字节”。

IOS12 below IOS12以下

a7eec1e7b1514058683ebae8e1d86b6b37d4b0e8f6316cbfcd2b42c5ec5952e450c8b0b68e26cbb560fcbc158261c3d7365125b9ec0fb4f7b484beeaf12827ba04c7e8e86b735e04427e0f3957fda8c0ca3133c1d8f4218a415b8740422b41a60bf54e3f8c32d0d3fba4a9de1d59fc4603c97baa6387f1f0b9b27b1e0722350f04b763f002d38afe99553b1511e8c12db3aae59f30a02b44529d3c4866b9449cdb40b60a7b19dbf5e4e47da39c1c3995470c463cf82dfdb1247f7d524076292248f31b43d49c31ec4f76233763190e2c a7eec1e7b1514058683ebae8e1d86b6b37d4b0e8f6316cbfcd2b42c5ec5952e450c8b0b68e26cbb560fcbc158261c3d7365125b9ec0fb4f7b484beeaf12827ba04c7e8e86b735e04427e0f3957fda8c0ca3133c1d8f4218a415b8740422b41a60bf54e3f8c32d0d3fba4a9de1d59fc4603c97baa6387f1f0b9b27b1e0722350f04b763f002d38afe99553b1511e8c12db3aae59f30a02b44529d3c4866b9449cdb40b60a7b19dbf5e4e47da39c1c3995470c463cf82dfdb1247f7d524076292248f31b43d49c31ec4f76233763190e2c

IOS13 above. IOS13 以上。

{length=208,bytes=0xa7eec1e7b1514058683ebae8e1d86b6b...fac0266ed36ff1ef} {长度=208,字节=0xa7eec1e7b1514058683ebae8e1d86b6b...fac0266ed36ff1ef}

What i want is to get only the bytes in IOS13.我想要的是仅获取 IOS13 中的字节。 Sorry for my bad english.对不起,我的英语不好。 and Thanks for the helps并感谢您的帮助

First of all, yours is not the more accurate way to ask a question here but let's try to solve it anyways:首先,您的问题不是在这里提出问题的更准确方法,但无论如何让我们尝试解决它:

I guess that you are obtaining that encryption from some data doing something like:我猜你是从一些数据中获得加密的,比如:

NSString *encryptionString = [NSString stringWithFormat:@"%@",encryptionData];

In the past iOS versions it used to work ok returning only the String, but starting in iOS13 you will get the description of the data, something like:在过去的 iOS 版本中,它曾经可以正常工作,仅返回字符串,但从 iOS13 开始,您将获得数据的描述,例如:

$1 = 0x0000000283373150 @"{length = 32, bytes = 0xf394ff84 a55f406d 165ab4fd d17eca51 ... 5c4cfdd1 06856852 }"

Nowadays you need to transform the data, sending the data to method as follows:现在你需要转换数据,将数据发送到方法如下:

NSString * encryptionString = [self stringFromData: encryptionData];

The method to be called is:要调用的方法是:

- (NSString *) stringFromData:(NSData *)myData {
    NSUInteger length = myData.length;
    if (length == 0) {
        return nil;
    }
    const unsigned char *buffer = myData.bytes;
    NSMutableString *hexString  = [NSMutableString stringWithCapacity:(length * 2)];
    for (int i = 0; i < length; ++i) {
        [hexString appendFormat:@"%02x", buffer[i]];
    }
    return [hexString copy];
}

This method will return the NSString that you want.此方法将返回您想要的 NSString。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM