parsec_tool/subcommands/
generate_random.rs1use crate::error::Result;
7use log::info;
8use parsec_client::BasicClient;
9use structopt::StructOpt;
10
11#[derive(Debug, StructOpt)]
13pub struct GenerateRandom {
14 #[structopt(short = "n", long = "nbytes")]
15 nbytes: usize,
16}
17
18impl GenerateRandom {
19 pub fn run(&self, basic_client: BasicClient) -> Result<()> {
21 info!("Generating {} random bytes...", self.nbytes);
22
23 let result = basic_client.psa_generate_random(self.nbytes)?;
24
25 info!("Random bytes:");
26 for byte in result {
27 print!("{:02X} ", byte);
28 }
29 println!();
30 Ok(())
31 }
32}