Browse Source

completet crate_vec()

master
Julian Graf 2 years ago
parent
commit
2b925bdc0d
1 changed files with 14 additions and 4 deletions
  1. 14
    4
      src/bin/message.rs

+ 14
- 4
src/bin/message.rs View File

@@ -48,13 +48,23 @@ impl Message {
msg.payload[0] = msg_type as u8;
msg
}
fn creat_vec(ciphertext: Vec<u8>) -> Vec<u8> {
let mut vec: Vec<u8> = vec![0; 14 + ciphertext.len()];
fn creat_vec(&mut self) -> Vec<u8> {
let mut vec: Vec<u8> = vec![0; (10 + self.size).into()];

vec[0] = ((self.src_id >> 24) & 0xff) as u8;
vec[1] = ((self.src_id >> 16) & 0xff) as u8;
vec[2] = ((self.src_id >> 8) & 0xff) as u8;
vec[3] = (self.src_id & 0xff) as u8;
vec[4] = ((self.dest_id >> 24) & 0xff) as u8;
vec[5] = ((self.dest_id >> 16) & 0xff) as u8;
vec[6] = ((self.dest_id >> 8) & 0xff) as u8;
vec[7] = (self.dest_id & 0xff) as u8;
vec[8] = ((self.size >> 8) & 0xff) as u8;
vec[9] = (self.size & 0xff) as u8;


for i in 14..(14 + ciphertext.len()){
vec[i] = ciphertext[i - 14];
for i in 10..(10 + self.size).into(){
vec[i] = self.payload[i - 10];
}
vec
}

Loading…
Cancel
Save