RCTPBKDF2.m 572 B

1234567891011121314151617181920
  1. #import "RCTPBKDF2.h"
  2. #import "PBKDF2.h"
  3. @implementation RCTPBKDF2
  4. RCT_EXPORT_MODULE()
  5. RCT_EXPORT_METHOD(derivationKey:(NSString *)password salt:(NSString *)salt iterations:(nonnull int *)iterations
  6. resolver:(RCTPromiseResolveBlock)resolve
  7. rejecter:(RCTPromiseRejectBlock)reject) {
  8. NSError *error = nil;
  9. NSString *data = [PBKDF2 derivationKey:password salt:salt iterations: iterations];
  10. if (data == nil) {
  11. reject(@"keygen_fail", @"Key generation failed", error);
  12. } else {
  13. resolve(data);
  14. }
  15. }
  16. @end