extern crate rand;
use rand::Rng;
use std::env;

const CYPHERBYTES: usize = 32;

fn main() {
    let args: Vec<_> = env::args().collect();
    if args.len() != 2 {
        println!("usage: {} file-to-encrypt", args[0]);
        return
    }

    let mut csprng = match rand::OsRng::new() {
        Ok(g) => g,
        Err(e) => panic!("Could not find a cryptographically-secure PRNG on the system. Details: {}", e)
    };

    let mut cyphertext = [0u8; CYPHERBYTES];
    csprng.fill_bytes(&mut cyphertext);
    for x in &cyphertext { print!("{:02x}", *x); }
    println!("")
}

extern crate rand;
use rand::Rng;
use std::env;

const CYPHERBYTES: usize = 32;

fn main() {
    let args: Vec<_> = env::args().collect();
    if args.len() != 2 {
        println!("usage: {} file-to-encrypt", args[0]);
        return
    }

    let mut rng = rand::thread_rng();

    let mut cyphertext = [0u8; CYPHERBYTES];
    rng.fill_bytes(&mut cyphertext);
    for x in &cyphertext { print!("{:02x}", *x); }
    println!("")
}

--- 
+++ 
@@ -11,10 +11,13 @@
         return
     }
 
-    let mut rng = rand::thread_rng();
+    let mut csprng = match rand::OsRng::new() {
+        Ok(g) => g,
+        Err(e) => panic!("Could not find a cryptographically-secure PRNG on the system. Details: {}", e)
+    };
 
     let mut cyphertext = [0u8; CYPHERBYTES];
-    rng.fill_bytes(&mut cyphertext);
+    csprng.fill_bytes(&mut cyphertext);
     for x in &cyphertext { print!("{:02x}", *x); }
     println!("")
 }
Use Cryptographically Secure PRNG instead of Rng

As stated in the Rust documentation:

> An application that requires an entropy source for cryptographic purposes
> must use OsRng, which reads randomness from the source that the operating
> system provides (e.g. /dev/urandom on Unixes or CryptGenRandom() on Windows).
> The other random number generators provided by this module are not suitable
> for such purposes.
