From 8bcd14f7d665f4f9359a345e32c9efb38e619e09 Mon Sep 17 00:00:00 2001 From: Mark Vayngrib Date: Sat, 23 Jan 2016 10:48:27 -0500 Subject: [PATCH] add seed in constantsToExport --- RNRandomBytes.m | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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