diff --git a/RNRandomBytes.m b/RNRandomBytes.m index 5474872..cd20853 100644 --- a/RNRandomBytes.m +++ b/RNRandomBytes.m @@ -19,10 +19,21 @@ RCT_EXPORT_MODULE() RCT_EXPORT_METHOD(randomBytes:(NSUInteger)length callback:(RCTResponseSenderBlock)callback) { - NSMutableData* bytes = [NSMutableData dataWithLength:length]; - SecRandomCopyBytes(kSecRandomDefault, length, [bytes mutableBytes]); - NSString *passphrase = [bytes base64EncodedStringWithOptions:0]; - callback(@[[NSNull null], passphrase]); + callback(@[[NSNull null], [self randomBytes:length]]); } +- (NSString *) randomBytes:(NSUInteger)length +{ + NSMutableData* bytes = [NSMutableData dataWithLength:length]; + SecRandomCopyBytes(kSecRandomDefault, length, [bytes mutableBytes]); + return [bytes base64EncodedStringWithOptions:0]; +} + +- (NSDictionary *)constantsToExport +{ + return @{ + @"seed": [self randomBytes:4096] + }; +}; + @end