{
Int32 dwLoop = 0,dwCharIndex = 0,dwCharCount = 0,dwRem = 0;
Char[] acPart = null;
StringBuilder sbOutput = null;
return null;
{
dwCharCount = abData.Length * 2;
sbOutput = new StringBuilder(dwCharCount);
acPart = new Char[2];
}
catch (Exception e)
{
Trace.WriteLine("CLsBase24.Encode: Initialize buffer failed! " + e.Message);
}
if (acPart == null || sbOutput == null)
return null;
{
Array.Clear(acPart,0,acPart.Length);
// ONE byte will split to TWO characters
Math.DivRem(dwLoop,9,out dwRem);
dwCharIndex = (abData[dwLoop] >> 4) + dwRem;
acPart[0] = m_acBaseMap[dwCharIndex];
dwCharIndex = (abData[dwLoop] & 0x0F) + dwRem;
acPart[1] = m_acBaseMap[dwCharIndex];
sbOutput.Append(acPart,0,acPart.Length);
}
}
{
Int32 dwLoop = 0,dwLength = 0,dwRem = 0;
Int32[] dwCharIndex = null;
Byte[] abOutput = null;
Char[] acInput = null;
return null;
if (acInput == null)
return null;
{
dwLength = acInput.Length / 2;
abOutput = new Byte[dwLength];
dwCharIndex = new Int32[2];
}
catch (Exception e)
{
Trace.WriteLine("CLsBase24.Decode: Initialize buffer failed! " + e.Message);
}
if (acInput == null)
return null;
for (dwLoop = 0;dwLoop < acInput.Length;dwLoop += 2)
{
Array.Clear(dwCharIndex,0,dwCharIndex.Length);
// TWO character can merage ONE byte
Math.DivRem(dwLoop / 2,9,out dwRem);
switch (acInput.Length - dwLoop)
{
case 1:
dwCharIndex[0] = GetCharIndex(acInput[dwLoop]) - dwRem;
abOutput[dwLength] = (Byte) (dwCharIndex[0] << 4);
break;
dwCharIndex[0] = GetCharIndex(acInput[dwLoop]) - dwRem;
dwCharIndex[1] = GetCharIndex(acInput[dwLoop + 1]) - dwRem;
abOutput[dwLength] = (Byte) ((dwCharIndex[0] << 4) + dwCharIndex[1]);
break;
dwLength++;
}
}