pub fn post_process_file_bin_block(bin_block: &mut Vec<u8>, integrity: &mut Option<Integrity>) {
    if let Some(integrity) = integrity {
        match integrity {
            Integrity::Crc32 => {
                let crc = crc32::checksum_ieee(bin_block);
                bin_block.extend_from_slice(&crc.to_le_bytes());
            },
            Integrity::Sha1Chain(prev_hash) => {
                let mut hash: [u8; 20] = [0; 20];
                blockchain_sha1(&prev_hash[..], bin_block, &mut hash);
                bin_block.extend_from_slice(&hash);
                *prev_hash = hash;
            },
            Integrity::Sha256Chain(prev_hash) => {
                let mut hash: [u8; 32] = [0; 32];
                blockchain_sha256(prev_hash, bin_block, &mut hash);
                bin_block.extend_from_slice(&hash);
                *prev_hash = hash;
            },
        }
    }
}
/// Depending on the settings in 'cfg', it adds a checksum, calculates the blockchain, compresses, encrypts, etc.
Depending on the settings in 'cfg', it adds a checksum, calculates the blockchain, compresses, encrypts, etc.
Depending on the settings in ' cfg ' it adds a checksum calculates the blockchain compresses encrypts etc .
pub fn post_process_file_bin_block(bin_block: &mut Vec<u8>, integrity: &mut Option<Integrity>) {
    if let Some(integrity) = integrity {
        match integrity {
            Integrity::Crc32 => {
                let crc = crc32::checksum_ieee(bin_block);
                bin_block.extend_from_slice(&crc.to_le_bytes());
            },
            Integrity::Sha1Chain(prev_hash) => {
                let mut hash: [u8; 20] = [0; 20];
                blockchain_sha1(&prev_hash[..], bin_block, &mut hash);
                bin_block.extend_from_slice(&hash);
                *prev_hash = hash;
            },
            Integrity::Sha256Chain(prev_hash) => {
                let mut hash: [u8; 32] = [0; 32];
                blockchain_sha256(prev_hash, bin_block, &mut hash);
                bin_block.extend_from_slice(&hash);
                *prev_hash = hash;
            },
        }
    }
}
pub fn post_process_file_bin_block ( bin_block : & mut Vec < u8 > , integrity : & mut Option < Integrity > ) { if let Some ( integrity ) = integrity { match integrity { Integrity :: Crc32 => { let crc = crc32 :: checksum_ieee ( bin_block ) ; bin_block . extend_from_slice ( & crc . to_le_bytes ( ) ) ; } , Integrity :: Sha1Chain ( prev_hash ) => { let mut hash : [ u8 ; 20 ] = [ 0 ; 20 ] ; blockchain_sha1 ( & prev_hash [ .. ] , bin_block , & mut hash ) ; bin_block . extend_from_slice ( & hash ) ; * prev_hash = hash ; } , Integrity :: Sha256Chain ( prev_hash ) => { let mut hash : [ u8 ; 32 ] = [ 0 ; 32 ] ; blockchain_sha256 ( prev_hash , bin_block , & mut hash ) ; bin_block . extend_from_slice ( & hash ) ; * prev_hash = hash ; } , } } }
Depending on the settings in 'cfg', it adds a checksum, calculates the blockchain, compresses, encrypts, etc.
Depending on the settings in ' cfg ' it adds a checksum calculates the blockchain compresses encrypts etc .
bin_block
&mut Vec<u8>
integrity
&mut Option<Integrity>
bin_block
&mut Vec<u8>
integrity
&mut Option<Integrity>