pub static ALPHABET32_ENCODE:&'static[u8;32]=&[
065,066,067,068,069,070,071,072,
073,074,075,076,077,078,079,080,
081,082,083,084,085,086,087,088,
089,090,050,051,052,053,054,055
];
pub static ALPHABET32_DECODE:&'static[u8;256]=&[
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,026,027,028,029,030,031,
255,255,255,255,255,255,255,255,
255,000,001,002,003,004,005,006,
007,008,009,010,011,012,013,014,
015,016,017,018,019,020,021,022,
023,024,025,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255
];
pub struct B32<T>(T);
pub trait B32Encode<I,O>{
fn encode(data:I)->O;
}
pub trait B32Decode<I,O>{
fn validation(data:I)->B32DecodeError;
fn decode(data:I)->Result<O,B32DecodeError>;
unsafe fn unsafe_decode(data:I)->O;
}
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum B32DecodeError{
Null,
InvalidByte,
InvalidPadding,
InvalidLength
}
fn b32_validation(ptd:*const u8,len:usize,pta:*const u8,max_pad:usize,pad:u8,rem:usize,min_len:usize)->B32DecodeError{
if len<min_len {return B32DecodeError::InvalidLength;}
if len==0 {return B32DecodeError::Null;}
if len%rem!=0 {return B32DecodeError::InvalidLength;}
let mut ind:isize=len as isize;
#[allow(unused_parens)]
unsafe{while({ind-=1;ind>0 && (*ptd.offset(ind)==61)}){}}
let pdl=len-1-ind as usize;
if pdl>max_pad {return B32DecodeError::InvalidPadding;}
if ((pad>>pdl)&0b1)==0 {return B32DecodeError::InvalidPadding;}
unsafe{while ind>-1{if *pta.offset(*ptd.offset(ind) as isize)==255{return B32DecodeError::InvalidByte;}ind-=1;}}
return B32DecodeError::Null;
}
include!("include/encode/be_encode.rs");
include!("include/encode/le_encode.rs");
include!("include/decode/le_decode.rs");
#[cfg(target_endian = "little")]
const b32_encode_1:fn(*const u8,usize,*const u8)->String=b32_encode_le_1;
#[cfg(target_endian = "little")]
const b32_encode_2:fn(*const u8,usize,*const u8)->String=b32_encode_le_2;
#[cfg(target_endian = "little")]
const b32_encode_4:fn(*const u8,usize,*const u8)->String=b32_encode_le_4;
#[cfg(target_endian = "little")]
const b32_encode_8:fn(*const u8,usize,*const u8)->String=b32_encode_le_8;
#[cfg(target_endian = "little")]
const b32_decode_1:fn(*const u8,usize,*const u8,*mut u8,usize)=b32_decode_le_1;
#[cfg(target_endian = "little")]
const b32_decode_2:fn(*const u8,usize,*const u8,*mut u8,usize)=b32_decode_le_2;
#[allow(dead_code)]
pub fn b32_decode(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;
}
}
}
}
include!("./include/u8.rs");
include!("./include/u16.rs");
include!("./include/u32.rs");
include!("./include/u64.rs");
include!("./include/i8.rs");
include!("./include/i16.rs");
include!("./include/i32.rs");
include!("./include/i64.rs");
include!("./include/vec_u8.rs");
include!("./include/vec_u16.rs");
include!("./include/vec_u32.rs");
include!("./include/vec_u64.rs");
include!("./include/vec_i8.rs");
include!("./include/vec_i16.rs");
include!("./include/vec_i32.rs");
include!("./include/vec_i64.rs");
include!("./include/string.rs");