| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | Base64Decode | (hzChain&,const char*,) |
Declared in file: hzCodec.h
Defined in file : hzCodec.cpp
Function Logic:
Function body:
hzEcode Base64Decode (hzChain& Decoded, const char* s)
{
_hzfunc("Base64Decode(cstr)") ;
const char* i ;
int32_t nBytes ;
int32_t val ;
int32_t a ;
int32_t b ;
int32_t c ;
int32_t d ;
Decoded.Clear() ;
nBytes = strlen(s) ;
if (nBytes % 4)
return hzerr(E_FORMAT, "Supplied string is not an exact multiple of 4 bytes in length") ;
for (i = s ; *i ;)
{
a = _get6bit(*i) ; i++ ;
b = _get6bit(*i) ; i++ ;
c = _get6bit(*i) ; i++ ;
d = _get6bit(*i) ; i++ ;
if (a == 101||b== 101||c== 101||d== 101)
return E_FORMAT ;
val = 0;
if (a < 100)val += (a << 18);
if (b < 100)val += (b << 12);
if (c < 100)val += (c << 6);
if (d < 100)val += d ;
a = (val & 0xff0000)>>16;
b = (val & 0xff00)>>8;
c = val & 0xff;
Decoded.AddByte(a) ;
if (b)
Decoded.AddByte(b) ;
if (c)
Decoded.AddByte(c) ;
if (*i == CHAR_NL) i++ ;
if (*i == CHAR_CR) i++ ;
}
return E_OK ;
}