获取设备上的所有App

NSString *rootAppPath = @"/Applications";

NSArray *listApp = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:rootAppPath error:nil];

NSLog(@"-----%@",listApp);



//HmacSHA1加密;

+(NSString *)HmacSha1:(NSString *)key data:(NSString *)data

{

const char *cKey  = [key cStringUsingEncoding:NSASCIIStringEncoding];

const char *cData = [data cStringUsingEncoding:NSASCIIStringEncoding];

//Sha256:

// unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];

//CCHmac(kCCHmacAlgSHA256, cKey, strlen(cKey), cData, strlen(cData), cHMAC);

//sha1

unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];

CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData, strlen(cData), cHMAC);

NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC

length:sizeof(cHMAC)];

NSString *hash = [HMAC base64EncodedStringWithOptions:0];//将加密结果进行一次BASE64编码。

return hash;

}

你可能感兴趣的:(获取设备上的所有App)