Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::io::{stdin, BufRead};
- fn print_state(state: [[u8; 8]; 8]) {
- for i in 0..8 {
- for j in 0..8 {
- print!("{}", state[i][j] as char);
- }
- println!();
- }
- }
- fn main() {
- println!("What do you want to encode?");
- let mut input_buf = String::new();
- stdin().lock().read_line(&mut input_buf).expect("Cannot read input.");
- let input = input_buf.trim();
- assert!(input.len() == 32);
- let mut buf = [[b'@'; 8]; 8];
- for (i, c) in input.chars().enumerate() {
- for j in 0..8 {
- buf[j][(i + j) % 8] |= (((c as u8) & (1 << j)) >> j) << (i / 8);
- }
- }
- print_state(buf);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement