Decode function in vb.net

  • Follow


This is a multi-part message in MIME format.

------=_NextPart_000_0008_01CA9B53.F61D32E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I am having encode & decode functions in C.
Will get an encoded value in vb.net & this must be decoded using vb.net =
code.=20
How can I apply this?

The decode function in C is

/*Decode function to decode the incoming buffer containing encoded =
data*/
void decode(char *inbuf,int sizeInbuffer,char *outbuf,int =
*decodeoutbufsize)
{
  /*Local Declaration*/=20
  unsigned char in[4], out[3], v;
  int i, len,j;
  int counter=3D0;
  int a1=3D0;

  for(j=3D0;j<sizeInbuffer;j=3Dj+4)
  {
   for( len =3D 0, i =3D 0; i < 4; i++ )=20
   {
    v =3D 0;
    while(v=3D=3D0)
    {
     v=3D(unsigned char) inbuf[counter++];
     v =3D (unsigned char) ((v < 43 || v > 122) ? 0 : cd64[ v - 43 ]);
     if( v )=20
     {
      v =3D (unsigned char) ((v =3D=3D '$') ? 0 : v - 61);
     }
    }
    len++;
    if( v )=20
    {
     in[ i ] =3D (unsigned char) (v - 1);
    }
   }

   if( len )=20
   {
    decodeblock( in, out );
    memcpy(outbuf+a1,out,3);
   // printf("%d",strlen(outbuf));
    a1+=3D3;
   }
  }

  *decodeoutbufsize =3D a1; //Done at SetDecodedLengthForOrderMsg(). =
Subtract by 2 since we have only 439 bytes, Last 1 byte also decoded =
with more than one byte(i.e, two bytes).
  return;
}



--=20
Regards
Valli
------=_NextPart_000_0008_01CA9B53.F61D32E0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16945" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT size=3D2>Hi,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I am having encode &amp; decode functions in =
C.</FONT></DIV>
<DIV><FONT size=3D2>Will get an encoded value in vb.net &amp; this must =
be decoded=20
using vb.net code. </FONT></DIV>
<DIV><FONT size=3D2>
<DIV><FONT size=3D2>How can I apply this?</FONT></DIV>
<DIV>&nbsp;</DIV></FONT></DIV>
<DIV><FONT size=3D2>The decode function in C is</FONT></DIV>
<DIV><FONT size=3D2></FONT><BR><FONT size=3D2>/*Decode function to =
decode the=20
incoming buffer containing encoded data*/<BR>void decode(char *inbuf,int =

sizeInbuffer,char *outbuf,int =
*decodeoutbufsize)<BR>{<BR>&nbsp;&nbsp;/*Local=20
Declaration*/&nbsp;<BR>&nbsp;&nbsp;unsigned char in[4], out[3],=20
v;<BR>&nbsp;&nbsp;int i, len,j;<BR>&nbsp;&nbsp;int =
counter=3D0;<BR>&nbsp;&nbsp;int=20
a1=3D0;</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT=20
size=3D2>&nbsp;&nbsp;for(j=3D0;j&lt;sizeInbuffer;j=3Dj+4)<BR>&nbsp;&nbsp;=
{<BR>&nbsp;&nbsp;&nbsp;for(=20
len =3D 0, i =3D 0; i &lt; 4; i++ )=20
<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;v =3D=20
0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;while(v=3D=3D0)<BR>&nbsp;&nbsp;&nbsp;&nbsp;=
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v=3D(unsigned=20
char) inbuf[counter++];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v =3D (unsigned =
char) ((v=20
&lt; 43 || v &gt; 122) ? 0 : cd64[ v - 43=20
]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( v )=20
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;v =3D=20
(unsigned char) ((v =3D=3D '$') ? 0 : v -=20
61);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&=
nbsp;&nbsp;&nbsp;&nbsp;len++;<BR>&nbsp;&nbsp;&nbsp;&nbsp;if(=20
v ) <BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in[ i =
] =3D=20
(unsigned char) (v -=20
1);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;if( len )=20
<BR>&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;decodeblock( in, out=20
);<BR>&nbsp;&nbsp;&nbsp;&nbsp;memcpy(outbuf+a1,out,3);<BR>&nbsp;&nbsp;&nb=
sp;//&nbsp;printf("%d",strlen(outbuf));<BR>&nbsp;&nbsp;&nbsp;&nbsp;a1+=3D=
3;<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;*decodeoutbufsize =3D a1;&nbsp;//Done at =

SetDecodedLengthForOrderMsg(). Subtract by 2 since we have only 439 =
bytes, Last=20
1 byte also decoded with more than one byte(i.e, two=20
bytes).<BR>&nbsp;&nbsp;return;<BR>}<BR></FONT></DIV>
<DIV><FONT size=3D2></FONT><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT><BR><FONT size=3D2>--=20
<BR>Regards<BR>Valli</FONT></DIV></BODY></HTML>

------=_NextPart_000_0008_01CA9B53.F61D32E0--

0
Reply Valli 1/22/2010 5:43:44 AM


0 Replies
260 Views

(page loaded in 0.046 seconds)

8/23/2012 12:00:39 PM


Reply: