| 10 | using namespace icinga; |
| 11 | |
| 12 | String Base64::Encode(const String& input) |
| 13 | { |
| 14 | BIO *biomem = BIO_new(BIO_s_mem()); |
| 15 | BIO *bio64 = BIO_new(BIO_f_base64()); |
| 16 | BIO_push(bio64, biomem); |
| 17 | BIO_set_flags(bio64, BIO_FLAGS_BASE64_NO_NL); |
| 18 | BIO_write(bio64, input.CStr(), input.GetLength()); |
| 19 | (void) BIO_flush(bio64); |
| 20 | |
| 21 | char *outbuf; |
| 22 | long len = BIO_get_mem_data(biomem, &outbuf); |
| 23 | |
| 24 | String ret = String(outbuf, outbuf + len); |
| 25 | BIO_free_all(bio64); |
| 26 | |
| 27 | return ret; |
| 28 | } |
| 29 | |
| 30 | String Base64::Decode(const String& input) |
| 31 | { |