Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Commit

Permalink
Fixed Crypto::Base64::encode for newer OpenSSL versions
Browse files Browse the repository at this point in the history
  • Loading branch information
eidheim committed Dec 5, 2016
1 parent 3be8772 commit 3821ece
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crypto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ namespace SimpleWeb {
template<class type>
void encode(const type& ascii, type& base64) {
BIO *bio, *b64;
BUF_MEM *bptr;
BUF_MEM *bptr=BUF_MEM_new();

b64 = BIO_new(BIO_f_base64());
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
bio = BIO_new(BIO_s_mem());
BIO_push(b64, bio);
BIO_get_mem_ptr(b64, &bptr);

BIO_set_mem_buf(b64, bptr, BIO_CLOSE);
//Write directly to base64-buffer to avoid copy
int base64_length=static_cast<int>(round(4*ceil((double)ascii.size()/3.0)));
base64.resize(base64_length);
Expand Down

0 comments on commit 3821ece

Please sign in to comment.