lundi 20 mars 2023

Smart Python random hexadecimal in Rust?

Python has a very convenient way to get cryptographically secure random hexadecimal; secrets.token_hex(n)

So by running secrets.token_hex(8) you get 16 hexadecimal, secrets.token_hex(12) gives 24 hexadecimal and so on. There is basically no upper lever. The number in the parentheses is in bytes.

My question, as recently started to learn Rust, is if there is a similar smart way to get a very high randomized hexadecimal output?

In Python:

import secrets


for x in range(1):
    xxx = secrets.token_hex(8)
   



Aucun commentaire:

Enregistrer un commentaire