Objective-C 的 BigNum 库。使用 OpenSSL。
CocoaPods 是 Objective-C 的依赖管理器,它自动化并简化了在项目中使用第三方库的过程。
platform :ios, "7.0"
pod "GHBigNum"
这仅包括我需要的几个大数方法,所以它仍在进行中。
GHBigNum *a = [GHBigNum bigNumWithDecimalString:@"3487438743234789234879"];
GHBigNum *p = [GHBigNum bigNumWithDecimalString:@"22"];
GHBigNum *m = [GHBigNum bigNumWithDecimalString:@"43234789234880"];
GHBigNum *r = [GHBigNum modPow:a p:p m:m];
GHBigNum *a = [GHBigNum bigNumWithDecimalString:@"3487438743234789234879"];
GHBigNum *m = [GHBigNum bigNumWithDecimalString:@"743234789234880"];
GHBigNum *r = [GHBigNum modInverse:a m:m];
GHBigNum *bn = [GHBigNum generatePrime:512];
[bn isPrime]; // YES