Starting Cryptopals challenge 1
commit
075cfc05d1
|
@ -0,0 +1,2 @@
|
||||||
|
target/
|
||||||
|
Cargo.lock
|
|
@ -0,0 +1,6 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "chal1"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "chal1"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["beneth <bmauduit@beneth.fr>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
|
@ -0,0 +1,19 @@
|
||||||
|
use std::env;
|
||||||
|
|
||||||
|
fn hex_to_char(s: &str) -> Result<char, std::num::ParseIntError> {
|
||||||
|
u8::from_str_radix(s, 16).map(|n| n as char)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
let input = &args[1];
|
||||||
|
|
||||||
|
let char_vec: Vec<char> = input.chars().collect();
|
||||||
|
let split = &char_vec.chunks(2)
|
||||||
|
.map(|chunk| chunk.iter().collect::<String>())
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
for s in split {
|
||||||
|
println!("{:?}", hex_to_char(s));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue