fn generate_password(recv_struct: RecivedPasswordStruct) -> String {
	let choice: u8 = recv_struct.choice;
	let max_length: u16 = recv_struct.max_length;

	let pre_byte_padding: String = recv_struct.pre_byte_padding;
	let pre_byte_padding_len: u16 = pre_byte_padding.len() as u16;

	let post_byte_padding: String = recv_struct.post_byte_padding;
	let post_byte_padding_len: u16 = post_byte_padding.len() as u16;

	let max_hash_char_len: u8 = (max_length / (pre_byte_padding_len + post_byte_padding_len + 1)) as u8;

	if max_length < 1 {
		panic!("The attribute max_length must be > 1 !  (Currently {})", max_length);
	}

	let hashed: String = generate_hexed_hash_bytes(recv_struct.pwd + &recv_struct.site)[0..max_length as usize].to_string();
	let mut final_hash: String = "".to_string();
		let mut index:u8 = 0; 
		for mut b in hashed.chars() {

			let b_as_uint: u8 = b as u8;

			if choice == 0 || choice == 1 { //0 = upper -> lower [AaAa...] | 1 = lower -> upper [aAaA...]
					if is_alphabet_character(b_as_uint) {
						if index & 1 == choice {
							b = invert_case(b_as_uint) as char;
						} 
					}

			} else if choice == 2 { //Uppercase
				if is_character_lowercase(b_as_uint) {
					b = invert_case(b_as_uint) as char;
				}

			} else if choice == 3 { //Lowercase
				if !is_character_lowercase(b_as_uint) {
					b = invert_case(b_as_uint) as char;
				}
			}

			if pre_byte_padding_len != 0 {
				final_hash += &pre_byte_padding;
			}

			final_hash.push(b);

			if post_byte_padding_len != 0 {
				final_hash += &post_byte_padding;
			}

			if (max_hash_char_len - 1) == index {
				break;
			}

			index += 1;
		}

	return final_hash;
}
//Generate the hash based on the received parameters
Generate the hash based on the received parameters
Generate the hash based on the received parameters
fn generate_password(recv_struct: RecivedPasswordStruct) -> String {
	let choice: u8 = recv_struct.choice;
	let max_length: u16 = recv_struct.max_length;
	let pre_byte_padding: String = recv_struct.pre_byte_padding;
	let pre_byte_padding_len: u16 = pre_byte_padding.len() as u16;
	let post_byte_padding: String = recv_struct.post_byte_padding;
	let post_byte_padding_len: u16 = post_byte_padding.len() as u16;
	let max_hash_char_len: u8 = (max_length / (pre_byte_padding_len + post_byte_padding_len + 1)) as u8;
	if max_length < 1 {
		panic!("The attribute max_length must be > 1 !  (Currently {})", max_length);
	}
	let hashed: String = generate_hexed_hash_bytes(recv_struct.pwd + &recv_struct.site)[0..max_length as usize].to_string();
	let mut final_hash: String = "".to_string();
		let mut index:u8 = 0; 
		for mut b in hashed.chars() {
			let b_as_uint: u8 = b as u8;
			if choice == 0 || choice == 1 { //0 = upper -> lower [AaAa...] | 1 = lower -> upper [aAaA...]
					if is_alphabet_character(b_as_uint) {
						if index & 1 == choice {
							b = invert_case(b_as_uint) as char;
						} 
					}
			} else if choice == 2 { //Uppercase
				if is_character_lowercase(b_as_uint) {
					b = invert_case(b_as_uint) as char;
				}
			} else if choice == 3 { //Lowercase
				if !is_character_lowercase(b_as_uint) {
					b = invert_case(b_as_uint) as char;
				}
			}
			if pre_byte_padding_len != 0 {
				final_hash += &pre_byte_padding;
			}
			final_hash.push(b);
			if post_byte_padding_len != 0 {
				final_hash += &post_byte_padding;
			}
			if (max_hash_char_len - 1) == index {
				break;
			}
			index += 1;
		}
	return final_hash;
}
fn generate_password ( recv_struct : RecivedPasswordStruct ) -> String { let choice : u8 = recv_struct . choice ; let max_length : u16 = recv_struct . max_length ; let pre_byte_padding : String = recv_struct . pre_byte_padding ; let pre_byte_padding_len : u16 = pre_byte_padding . len ( ) as u16 ; let post_byte_padding : String = recv_struct . post_byte_padding ; let post_byte_padding_len : u16 = post_byte_padding . len ( ) as u16 ; let max_hash_char_len : u8 = ( max_length / ( pre_byte_padding_len + post_byte_padding_len + 1 ) ) as u8 ; if max_length < 1 { panic ! ( " " max_length ) ; } let hashed : String = generate_hexed_hash_bytes ( recv_struct . pwd + & recv_struct . site ) [ 0 .. max_length as usize ] . to_string ( ) ; let mut final_hash : String = " " . to_string ( ) ; let mut index : u8 = 0 ; for mut b in hashed . chars ( ) { let b_as_uint : u8 = b as u8 ; if choice == 0 || choice == 1 { //0 = upper -> lower [AaAa...] | 1 = lower -> upper [aAaA...] if is_alphabet_character ( b_as_uint ) { if index & 1 == choice { b = invert_case ( b_as_uint ) as char ; } } } else if choice == 2 { //Uppercase if is_character_lowercase ( b_as_uint ) { b = invert_case ( b_as_uint ) as char ; } } else if choice == 3 { //Lowercase if ! is_character_lowercase ( b_as_uint ) { b = invert_case ( b_as_uint ) as char ; } } if pre_byte_padding_len != 0 { final_hash += & pre_byte_padding ; } final_hash . push ( b ) ; if post_byte_padding_len != 0 { final_hash += & post_byte_padding ; } if ( max_hash_char_len - 1 ) == index { break ; } index += 1 ; } return final_hash ; }
Generate the hash based on the received parameters
Generate the hash based on the received parameters
recv_struct
RecivedPasswordStruct