Tag: base64

如何在C中将图像转换为base64?

我需要将JPG图像转换为BASE64以插入到Cassandra集群中,所有在C中,我发现这个如何在C中进行base64编码(解码)? 但是如果我试图将fRead的结果放在图像上,它就会出现分段错误,(不可打印的caracters似乎会产生问题) /* ———————————————————————————-Includes DO NOT MODIFY———————————————————————————————- */ #include #include #include #include #include #include #include #include “cassandra.h” #include “../headers/other.h” size_t fileLen; /* —————————————————————————————CONFIG HERE !—————————————————————————————————*/ /* ———Connection———- */ const char *server_adress = “127.0.0.1”; /* Insert your server adress here */ const char *keyframe = “hallo”; /* Insert name of the table you want to insert […]

计算Base 64编码消息的大小

我有一个二进制字符串,我在Base 64编码。现在,我需要事先了解最终的Base 64编码字符串的大小。 有没有办法计算出来? 就像是: BinaryStringSize是64Kb编码后,EncodedBinaryStringSize将为127Kb。 哦,代码在C中。 谢谢。

生成随机n字节Base64字符串后的不可打印字符

我试图使用openssl生成一个32byte base64字符串,但它并不总是产生32字节字符串,有时输出是乱码并且没有正确显示 #include #include #include #include #include #include #include int Base64Encode(const unsigned char* buffer, unsigned char** b64text) { //Encodes a binary safe base 64 string BIO *bio, *b64; BUF_MEM *bufferPtr; b64 = BIO_new(BIO_f_base64()); bio = BIO_new(BIO_s_mem()); bio = BIO_push(b64, bio); BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL); //Ignore newlines – write everything in one line BIO_write(bio, buffer, strlen(buffer)); BIO_flush(bio); BIO_get_mem_ptr(bio, […]