+ (NSString *)pinxCreator:(NSString *)pan withPinv:(NSString *)pinv { if (pan.length != pinv.length) { return nil; } const char *panchar = [pan UTF8String]; const char *pinvchar = [pinv UTF8String]; NSString *temp = [[NSString alloc] init]; for (int i = 0; i < pan.length; i++) { int panValue = [self charToint:panchar[i]]; int pinvValue = [self charToint:pinvchar[i]]; temp = [temp stringByAppendingString:[NSString stringWithFormat:@"%X",panValue^pinvValue]]; } return temp; } + (int)charToint:(char)tempChar { if (tempChar >= ‘0‘ && tempChar <=‘9‘) { return tempChar - ‘0‘; } else if (tempChar >= ‘A‘ && tempChar <= ‘F‘) { return tempChar - ‘A‘ + 10; } return 0; }
测试数据
pan = @"0000001045670006";
pinv= @"06123456FFFFFFFF";
时间: 2024-10-12 23:34:42