processing_code/
lib.rs

1//! # **processing_code**
2//! It's a simply crate I wrote for fun<br>  
3//! It's used to encode and decode with the password which users give<br>
4//! And it's just use XOR
5
6/// get a password and content
7/// then processing the content with the password
8/// # Example
9/// ```
10/// let password = "Password";
11/// let content = "Content";
12///
13/// let encode = processing_code(password, content);
14/// println!("{}", encode);
15///
16/// let decode = processing_code(password, &encode);
17/// assert_eq!(content, decode);
18/// ```
19pub fn processing_code(password: &str, content: &str) -> String {
20    let password = password.as_bytes();
21    let content: Vec<u8> = content
22        .chars()
23        .map(|x| {
24            let mut new: u8 = 0;
25            password.iter().for_each(|y| new = x as u8 ^ y);
26            new
27        })
28        .collect();
29    content.iter().map(|x| *x as char).collect::<String>()
30}