惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - 秋忆

跑在Docker下的RHEL7编译Java8源码包 利用pyinotify监控文件内容,像tailf命令但比它更强 AWS SDK for C++调用第三方S3 API Windows 10恢复Shift+右键打开命令提示符窗口 TP-LINK WR841N V8刷OpenWRT Build subversion 1.8 with SSL on OS X Yosemite OpenWrt自定义和官方一样的固件 Windows 10下通过蓝牙连接iPhone个人热点进行共享上网 Broadcom有线网卡在Windows 8/8.1/10下使用系统自带驱动会断网的解决办法 BCM94352HMB蓝牙BCM20702A0在Ubuntu 14.04下的驱动方法 C语言实现GPT头和分区表的读取(gcc) 把Windows CA根证书安装到iPhone 编程实现设置“启动与故障恢复”的“在需要时显示恢复选项的时间” 笔记本电脑键盘状态助手KeyboardState Windows x64与x86混合编程需要注意的API 查看.NET程序集编译类型命令corflags 开启Windows7多用户远程桌面 Windows优化大师已经成为“流氓大师” C#打开目录并选中文件(夹)的实现
C/C++用OpenSSL库进行Base64编码
秋忆 · 2013-01-10 · via 博客园 - 秋忆

#include <string.h>
#include <openssl/pem.h>

size_t bc_base64_encode(const void *data, int data_len, char *buffer)
{
    BIO *b64 = BIO_new(BIO_f_base64());
    BIO *bio = BIO_new(BIO_s_mem());

    bio = BIO_push(b64, bio);
    BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
    BIO_write(bio, data, data_len);
    BIO_ctrl(bio, BIO_CTRL_FLUSH, 0, NULL);

    BUF_MEM *bptr = NULL;
    BIO_get_mem_ptr(bio, &bptr);

    size_t slen = bptr->length;
    memcpy(buffer, bptr->data, slen);
    buffer[slen] = '\0';

    BIO_free_all(bio);
    return slen;
}