code_junkie

How to find the size of decoded base64 data in C

Nov 12th, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. unsigned char *unbase64(unsigned char *input, int length)
  2. {
  3. BIO *b64, *bmem;
  4.  
  5. unsigned char *buffer = (unsigned char *)malloc(length);
  6. memset(buffer, 0, length);
  7.  
  8. b64 = BIO_new(BIO_f_base64());
  9. bmem = BIO_new_mem_buf(input, length);
  10. bmem = BIO_push(b64, bmem);
  11.  
  12. BIO_read(bmem, buffer, length);
  13.  
  14. BIO_free_all(bmem);
  15.  
  16. return buffer;
  17. }
Add Comment
Please, Sign In to add comment