No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.rs 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. extern crate clap;
  2. extern crate time;
  3. use clap::{Arg, App, SubCommand};
  4. mod hasher_sha256;
  5. mod hash256;
  6. pub fn main(/*base: usize, */number: usize, diff: String) {
  7. let matches = create_app().get_matches();
  8. let base;
  9. match matches.value_of("base") {
  10. Some(x) => {base = u64::from(x)}
  11. None => {panic!()}
  12. };
  13. match hash256::verify_product(base, number, diff) {
  14. Some(x) => { println!("{}", diff); }
  15. None => { println!("None"); }
  16. }
  17. }
  18. fn create_app<'a, 'b>() -> App<'a, 'b> {
  19. App::new("Hash256")
  20. .version("1.0")
  21. .author("Lorenz Bung & Joshua Rutschmann")
  22. .about("Calculates the Hashvalue of the given base, number and difficulty.")
  23. .arg(Arg::with_name("base")
  24. .short("b")
  25. .long("base")
  26. .value_name("VALUE")
  27. .help("The base of the hash to be calculated on.")
  28. .takes_value(true)
  29. .required(true))
  30. .arg(Arg::with_name("number")
  31. .short("n")
  32. .long("number")
  33. .value_name("VALUE")
  34. .help("The number of the hash to be calculated on.")
  35. .takes_value(true)
  36. .required(true))
  37. .arg(Arg::with_name("difficulty")
  38. .short("d")
  39. .long("difficulty")
  40. .value_name("VALUE")
  41. .help("The difficulty of the calculated hash.")
  42. .takes_value(true)
  43. .required(true))
  44. .subcommand(SubCommand::with_name("timings")
  45. .about("controls timing features")
  46. .version("1.0")
  47. .author("Lorenz Bung & Joshua Rutschmann"))
  48. }