Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OpenSSL C example Base64 Decode,

482 views
Skip to first unread message

Nigel Sollars

unread,
Sep 4, 2009, 2:36:58 PM9/4/09
to
HI all,

I have a working example of Encoding base64 using the BIO methods but
decrypting a string is being somewhat problematic. The code in the man
page for decoding does not work either as the stdin new_fp does not hand
off / stop listening for input.

The openssl version is 0.9.8i

If anyone could supply a working example I would appreciate it,

Regards
Nigel
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org

Hazel John

unread,
Sep 4, 2009, 2:50:13 PM9/4/09
to
This works for me:
void base64Decode(unsigned char* pIn, int inLen, unsigned char* pOut,
int& outLen)
{
// create a memory buffer containing base64 encoded data
BIO* bmem =3D BIO_new_mem_buf((void*)pIn, inLen);

// push a Base64 filter so that reading from buffer decodes it
BIO *bioCmd =3D BIO_new(BIO_f_base64());
// we don't want newlines
BIO_set_flags(bioCmd, BIO_FLAGS_BASE64_NO_NL);
bmem =3D BIO_push(bioCmd, bmem);

int finalLen =3D BIO_read(bmem, (void*)pOut, outLen);
BIO_free_all(bmem);
outLen =3D finalLen;
}

On Fri, Sep 4, 2009 at 1:37 PM, Nigel Sollars<n...@vx.com> wrote:
> HI all,
>
> I have a working example of Encoding base64 using the BIO methods but

> decrypting a string is being somewhat problematic. =A0The code in the man=


page
> for decoding does not work either as the stdin new_fp does not hand off /
> stop listening for input.
>
> The openssl version is 0.9.8i
>
> If anyone could supply a working example I would appreciate it,
>
> Regards
> Nigel
> ______________________________________________________________________

> OpenSSL Project =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 http://www.openssl.org
> User Support Mailing List =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0openssl-=
us...@openssl.org
> Automated List Manager =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 majo...@openssl.org

0 new messages