Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
PWS_BASE64_ENCODE(3)   FreeBSD Library Functions Manual	  PWS_BASE64_ENCODE(3)

NAME
     pws_base64_encode,	pws_base64_decode -- Encode and	decode strings to and
     from Base64

LIBRARY
     -lpwstor

SYNOPSIS
     #include <pwstor.h>

     unsigned char *
     pws_base64_encode(unsigned	char *src, unsigned char *dst, size_t len);

     unsigned char *
     pws_base64_decode(unsigned	char *src, unsigned char *dst);

DESCRIPTION
     The function pws_base64_encode() will encode len bytes of data from the
     memory referenced by pointer src and store	that data in the memory	refer-
     enced by pointer dst.  The	pointer	dst must be at least large enough to
     hold (( len * 2) +1) bytes	of data	just to	be on the safe side.  (While
     this isn't	technically correct, the actual	expansion is a fraction, which
     multiplying by floating point integers may	confuse	some inexperienced
     programmers who may then fall victim to buffer overflows.	Experienced
     developers	should know how	much memory is necessary and be	able to	calcu-
     late it more appropriately	to save	a few bytes, but *2 will always	work
     safely.)  The +1 is to allow for the storage of a null-terminating	byte,
     since pws_base64_decode expects its Base64-encoded	argument to be null-
     terminated.  Adding the null-terminating byte is up to the	application,
     however the safest	thing to do is generally to use	memset() or calloc()
     so	that the memory	buffer will be initialized to 0s regardless, and it
     can simply	be propagated by the pws_base64_encode() function.  A pointer
     to	the memory buffer referenced by	dst is returned.

     The function pws_base64_decode() can be used to decode data stored	in
     memory pointed to by src from Base64 back to its true value.  The true
     value will	be stored in the memory	pointed	to by dst.  Since src is
     Base64 encoded, it	is expected to be a null-terminated string.  The dst
     argument is expected to be	a pointer to a memory buffer large enough to
     store the results of decoding in.	A pointer to the memory	buffer refer-
     enced by dst is returned.

SEE ALSO
     pwstor(3)

FreeBSD	13.0		       October 23, 2008			  FreeBSD 13.0

NAME | LIBRARY | SYNOPSIS | DESCRIPTION | SEE ALSO

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=pws_base64_encode&sektion=3&manpath=FreeBSD+12.2-RELEASE+and+Ports>

home | help