Exemple #1
0
void CBase64::Decode(const PBYTE pBuffer, DWORD dwBufLen)
{
  if(!CBase64::m_Init)
    _Init();
  
  SetEncodeBuffer(pBuffer, dwBufLen);
  
  AllocDecode(dwBufLen);
  
  TempBucket      Raw;
  
  DWORD   nIndex = 0;
  
  while((nIndex + 4) <= m_nEDataLen)
  {
    Raw.Clear();
    Raw.nData[0] = CBase64::m_DecodeTable[m_pEBuffer[nIndex]];
    Raw.nData[1] = CBase64::m_DecodeTable[m_pEBuffer[nIndex + 1]];
    Raw.nData[2] = CBase64::m_DecodeTable[m_pEBuffer[nIndex + 2]];
    Raw.nData[3] = CBase64::m_DecodeTable[m_pEBuffer[nIndex + 3]];
    
    if(Raw.nData[2] == 255)
      Raw.nData[2] = 0;
    if(Raw.nData[3] == 255)
      Raw.nData[3] = 0;
    
    Raw.nSize = 4;
    _DecodeToBuffer(Raw, m_pDBuffer + m_nDDataLen);
    nIndex += 4;
    m_nDDataLen += 3;
  }
  
  // If nIndex < m_nEDataLen, then we got a decode message without padding.
  // We may want to throw some kind of warning here, but we are still required
  // to handle the decoding as if it was properly padded.
  if(nIndex < m_nEDataLen)
  {
    Raw.Clear();
    for(DWORD i = nIndex; i < m_nEDataLen; i++)
    {
      Raw.nData[i - nIndex] = CBase64::m_DecodeTable[m_pEBuffer[i]];
      Raw.nSize++;
      if(Raw.nData[i - nIndex] == 255)
        Raw.nData[i - nIndex] = 0;
    }
    
    _DecodeToBuffer(Raw, m_pDBuffer + m_nDDataLen);
    m_nDDataLen += (m_nEDataLen - nIndex);
  }
}
Exemple #2
0
void CBase64::Decode(const PBYTE pBuffer, DWORD dwBufLen)
{
	if (!CBase64::m_Init)  _Init();

	SetEncodeBuffer(pBuffer, dwBufLen);
	AllocDecode(dwBufLen);

	TempBucket Raw;
	DWORD   nIndex = 0;
	while((nIndex + 4) <= m_nEDataLen)
	{
		Raw.Clear();
		Raw.nData[0] = 
			CBase64::m_DecodeTable[m_pEBuffer[nIndex]];
	Raw.nData[1] = CBase64::m_DecodeTable[m_pEBuffer[nIndex + 1]];
	Raw.nData[2] = CBase64::m_DecodeTable[m_pEBuffer[nIndex + 2]];
	Raw.nData[3] = CBase64::m_DecodeTable[m_pEBuffer[nIndex + 3]];

		if (Raw.nData[2] == 255)  Raw.nData[2] = 0;
		if (Raw.nData[3] == 255)  Raw.nData[3] = 0;
 
		Raw.nSize = 4;
		_DecodeToBuffer(Raw, m_pDBuffer + m_nDDataLen);
		nIndex += 4;
		m_nDDataLen += 3;
	}
 
	if (nIndex < m_nEDataLen)
	{
		Raw.Clear();
		for (DWORD i=nIndex; i<m_nEDataLen; i++)
		{
			Raw.nData[i - nIndex] = 
			CBase64::m_DecodeTable[m_pEBuffer[i]];
			Raw.nSize++;
			if(Raw.nData[i - nIndex] == 255)
			Raw.nData[i - nIndex] = 0;
		}

		_DecodeToBuffer(Raw, m_pDBuffer + m_nDDataLen);
		m_nDDataLen += (m_nEDataLen - nIndex);
	}
}
Exemple #3
0
void CBase64::SetDecodeBuffer(const PBYTE pBuffer, DWORD nBufLen)
{
  AllocDecode(nBufLen);
  memcpy(m_pDBuffer, pBuffer, nBufLen);
  m_nDDataLen = nBufLen;
}
Exemple #4
0
void CBase64::SetDecodeBuffer(const unsigned char* pBuffer, unsigned long nBufLen)
{
  AllocDecode(nBufLen);
  ::CopyMemory(m_pDBuffer, pBuffer, nBufLen);
  m_nDDataLen = nBufLen;
}