fn encrypt(key: &String, clear: &Vec<u8>) -> String {
    let mut out_bytes : Vec<u8> = Vec::new();
    let key_bytes : Vec<u8> = key.as_bytes().to_vec();
    for i in 0..clear.len() {
        out_bytes.push(clear[i] ^ key_bytes[i % key_bytes.len()]);
    }
    //let encrypted_bytes = out_bytes.iter().map(|&c| c as char).collect::<String>();
    assert_eq!(out_bytes.len(), clear.len());
    base64::encode(&out_bytes)
}
// Helper function to encrypt data. Takes in a vector of bytes and returns a b64 string
Helper function to encrypt data. Takes in a vector of bytes and returns a b64 string
Helper function to encrypt data . Takes in a vector of bytes and returns a b64 string
fn encrypt(key: &String, clear: &Vec<u8>) -> String {
    let mut out_bytes : Vec<u8> = Vec::new();
    let key_bytes : Vec<u8> = key.as_bytes().to_vec();
    for i in 0..clear.len() {
        out_bytes.push(clear[i] ^ key_bytes[i % key_bytes.len()]);
    }
    //let encrypted_bytes = out_bytes.iter().map(|&c| c as char).collect::<String>();
    assert_eq!(out_bytes.len(), clear.len());
    base64::encode(&out_bytes)
}
fn encrypt ( key : & String , clear : & Vec < u8 > ) -> String { let mut out_bytes : Vec < u8 > = Vec :: new ( ) ; let key_bytes : Vec < u8 > = key . as_bytes ( ) . to_vec ( ) ; for i in 0 .. clear . len ( ) { out_bytes . push ( clear [ i ] ^ key_bytes [ i % key_bytes . len ( ) ] ) ; } //let encrypted_bytes = out_bytes.iter().map(|&c| c as char).collect::<String>(); assert_eq ! ( out_bytes len ( ) clear len ( ) ) ; base64 :: encode ( & out_bytes ) }
Helper function to encrypt data.
Helper function to encrypt data .
key
&String
clear
&Vec<u8>
key
&String
clear
&Vec<u8>