2021-01-14 21:18:49 -05:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2021-01-14 19:24:38 -05:00
|
|
|
use deno_crypto::op_crypto_get_random_values;
|
2020-11-13 16:01:57 -05:00
|
|
|
use deno_crypto::rand::rngs::StdRng;
|
|
|
|
use deno_crypto::rand::SeedableRng;
|
|
|
|
|
|
|
|
pub fn init(rt: &mut deno_core::JsRuntime, maybe_seed: Option<u64>) {
|
|
|
|
if let Some(seed) = maybe_seed {
|
|
|
|
let rng = StdRng::seed_from_u64(seed);
|
|
|
|
let op_state = rt.op_state();
|
|
|
|
let mut state = op_state.borrow_mut();
|
|
|
|
state.put::<StdRng>(rng);
|
|
|
|
}
|
2021-04-12 15:55:05 -04:00
|
|
|
super::reg_sync(
|
2021-01-14 19:24:38 -05:00
|
|
|
rt,
|
|
|
|
"op_crypto_get_random_values",
|
|
|
|
op_crypto_get_random_values,
|
|
|
|
);
|
2020-11-13 16:01:57 -05:00
|
|
|
}
|