wdg-base32 0.3.16

The Base32 Data Encoding
Documentation

// ready
pub fn b32_decode_le_1(ptr_input:*const u8,len_input:usize,ptr_alphabet:*const u8,mut pointer:*mut u8,np:usize){
    let mut ptr_data=ptr_input;
    let mut len_data=len_input;
    unsafe{
        while len_data>8{
            *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
            *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
            *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
            *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(5) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(6) as isize)>>3;
            *pointer.offset(4)=*ptr_alphabet.offset(*ptr_data.offset(6) as isize)<<5|*ptr_alphabet.offset(*ptr_data.offset(7) as isize)<<0;
            pointer=pointer.offset(5);
            ptr_data=ptr_data.offset(8);
            len_data-=8;
        }
        if len_data==8{
            if np>0{
                if np>3{
                    if np>5{
                        *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                        *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6;
                    }else{
                        *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                        *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
                        *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4;
                    }
                }else{
                    if np>2{
                        *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                        *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
                        *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
                        *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7;
                    }else{
                        *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                        *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
                        *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
                        *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(5) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(6) as isize)>>3;
                        *pointer.offset(4)=*ptr_alphabet.offset(*ptr_data.offset(6) as isize)<<5;
                    }
                }
            }else{
                *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
                *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
                *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(5) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(6) as isize)>>3;
                *pointer.offset(4)=*ptr_alphabet.offset(*ptr_data.offset(6) as isize)<<5|*ptr_alphabet.offset(*ptr_data.offset(7) as isize)<<0;
            }
        }
    }
}

// ready
pub fn b32_decode_le_2(ptr_input:*const u8,len_input:usize,ptr_alphabet:*const u8,mut pointer:*mut u8,np:usize){
    let mut ptr_data=ptr_input;
    let mut len_data=len_input;
    unsafe{
        while len_data > 16 {
            *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
            *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
            *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
            *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(5) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(6) as isize)>>3;
            *pointer.offset(5)=*ptr_alphabet.offset(*ptr_data.offset(6) as isize)<<5|*ptr_alphabet.offset(*ptr_data.offset(7) as isize)<<0;
            *pointer.offset(4)=*ptr_alphabet.offset(*ptr_data.offset(8) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(9) as isize)>>2;
            *pointer.offset(7)=*ptr_alphabet.offset(*ptr_data.offset(9) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(10) as isize)>>4;
            *pointer.offset(6)=*ptr_alphabet.offset(*ptr_data.offset(11) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(12) as isize)>>1;
            *pointer.offset(9)=*ptr_alphabet.offset(*ptr_data.offset(12) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(13) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(14) as isize)>>3;
            *pointer.offset(8)=*ptr_alphabet.offset(*ptr_data.offset(14) as isize)<<5|*ptr_alphabet.offset(*ptr_data.offset(15) as isize)<<0;

            pointer=pointer.offset(10);
            ptr_data=ptr_data.offset(16);
            len_data-=16;
        }

        if np > 0 {
            if np > 3 {
                if np == 4 {
                    *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                    *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
                }else{
                    *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                    *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
                    *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
                    *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(5) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(6) as isize)>>3;
                    *pointer.offset(5)=*ptr_alphabet.offset(*ptr_data.offset(6) as isize)<<5|*ptr_alphabet.offset(*ptr_data.offset(7) as isize)<<0;
                    *pointer.offset(4)=*ptr_alphabet.offset(*ptr_data.offset(8) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(9) as isize)>>2;
                }
            }else{
                if np == 1 {
                    *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                    *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
                    *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
                    *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(5) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(6) as isize)>>3;
                }else{
                    *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
                    *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
                    *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
                    *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(5) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(6) as isize)>>3;
                    *pointer.offset(5)=*ptr_alphabet.offset(*ptr_data.offset(6) as isize)<<5|*ptr_alphabet.offset(*ptr_data.offset(7) as isize)<<0;
                    *pointer.offset(4)=*ptr_alphabet.offset(*ptr_data.offset(8) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(9) as isize)>>2;
                    *pointer.offset(7)=*ptr_alphabet.offset(*ptr_data.offset(9) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(10) as isize)>>4;
                    *pointer.offset(6)=*ptr_alphabet.offset(*ptr_data.offset(11) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(12) as isize)>>1;
                }
            }
        }else{
            *pointer.offset(1)=*ptr_alphabet.offset(*ptr_data.offset(0) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(1) as isize)>>2;
            *pointer.offset(0)=*ptr_alphabet.offset(*ptr_data.offset(1) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(2) as isize)<<1|*ptr_alphabet.offset(*ptr_data.offset(3) as isize)>>4;
            *pointer.offset(3)=*ptr_alphabet.offset(*ptr_data.offset(3) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(4) as isize)>>1;
            *pointer.offset(2)=*ptr_alphabet.offset(*ptr_data.offset(4) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(5) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(6) as isize)>>3;
            *pointer.offset(5)=*ptr_alphabet.offset(*ptr_data.offset(6) as isize)<<5|*ptr_alphabet.offset(*ptr_data.offset(7) as isize)<<0;
            *pointer.offset(4)=*ptr_alphabet.offset(*ptr_data.offset(8) as isize)<<3|*ptr_alphabet.offset(*ptr_data.offset(9) as isize)>>2;
            *pointer.offset(7)=*ptr_alphabet.offset(*ptr_data.offset(9) as isize)<<6|*ptr_alphabet.offset(*ptr_data.offset(10) as isize)>>4;
            *pointer.offset(6)=*ptr_alphabet.offset(*ptr_data.offset(11) as isize)<<4|*ptr_alphabet.offset(*ptr_data.offset(12) as isize)>>1;
            *pointer.offset(9)=*ptr_alphabet.offset(*ptr_data.offset(12) as isize)<<7|*ptr_alphabet.offset(*ptr_data.offset(13) as isize)<<2|*ptr_alphabet.offset(*ptr_data.offset(14) as isize)>>3;
            *pointer.offset(8)=*ptr_alphabet.offset(*ptr_data.offset(14) as isize)<<5|*ptr_alphabet.offset(*ptr_data.offset(15) as isize)<<0;
        }
    }
}