Loading openssl/src/rand.rs +19 −9 Original line number Diff line number Diff line //! Cryptographically strong random bytes. //! //! This module exposes functionality to put cryptographically strong //! pseudo-random bytes into a buffer. //! Utilities for secure random number generation. //! //! # Examples //! //! To generate a buffer with cryptographically strong bytes: //! //! ``` //! let muf buf = [0; 256]; //! use openssl::rand::rand_bytes; //! //! let mut buf = [0; 256]; //! rand_bytes(&mut buf).unwrap(); //! ``` //! //! # External OpenSSL Documentation //! //! [RAND_bytes](https://www.openssl.org/docs/man1.1.0/crypto/RAND_bytes.html) use libc::c_int; use ffi; Loading @@ -22,6 +17,21 @@ use cvt; use error::ErrorStack; /// Fill buffer with cryptographically strong pseudo-random bytes. /// /// # Examples /// /// To generate a buffer with cryptographically strong bytes: /// /// ``` /// use openssl::rand::rand_bytes; /// /// let mut buf = [0; 256]; /// rand_bytes(&mut buf).unwrap(); /// ``` /// /// # External OpenSSL Documentation /// /// [RAND_bytes](https://www.openssl.org/docs/man1.1.0/crypto/RAND_bytes.html) pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> { unsafe { ffi::init(); Loading Loading
openssl/src/rand.rs +19 −9 Original line number Diff line number Diff line //! Cryptographically strong random bytes. //! //! This module exposes functionality to put cryptographically strong //! pseudo-random bytes into a buffer. //! Utilities for secure random number generation. //! //! # Examples //! //! To generate a buffer with cryptographically strong bytes: //! //! ``` //! let muf buf = [0; 256]; //! use openssl::rand::rand_bytes; //! //! let mut buf = [0; 256]; //! rand_bytes(&mut buf).unwrap(); //! ``` //! //! # External OpenSSL Documentation //! //! [RAND_bytes](https://www.openssl.org/docs/man1.1.0/crypto/RAND_bytes.html) use libc::c_int; use ffi; Loading @@ -22,6 +17,21 @@ use cvt; use error::ErrorStack; /// Fill buffer with cryptographically strong pseudo-random bytes. /// /// # Examples /// /// To generate a buffer with cryptographically strong bytes: /// /// ``` /// use openssl::rand::rand_bytes; /// /// let mut buf = [0; 256]; /// rand_bytes(&mut buf).unwrap(); /// ``` /// /// # External OpenSSL Documentation /// /// [RAND_bytes](https://www.openssl.org/docs/man1.1.0/crypto/RAND_bytes.html) pub fn rand_bytes(buf: &mut [u8]) -> Result<(), ErrorStack> { unsafe { ffi::init(); Loading