Secure Random Source

In Random.zig there is a source implemented using random.

What If I want to use a different source using randomSecure?

With the previous API, It was possible using std.Options.crypto_always_getrandom.

Thanks.

it is odd that there isn’t an IoSource variant that uses randomSecure.

You could trivially make your own.

It’s also worth mentioning that there are cypto rng implementations in std that don’t need Io beyond seeding.

I assumed that it is not possible to implement a new source, because the code should be in the same file where Random is implemented.

Thanks.

std.Random is just a runtime interface, same as Allocator and Io. It would not be possible to stop you from implementing your own since fields can’t be private, and the type needs to be public.

Well, not without shenanigans at least :3