mirror of
https://github.com/status-im/react-native-randombytes.git
synced 2026-08-27 17:11:12 +00:00
add seed in constantsToExport
This commit is contained in:
+15
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user