将RSA加密消息转换为Base64格式!!! [英] Conversion of RSA Encrypted message to Base64 format !!!
问题描述
我已经完成了RSA加密程序.现在,我想将该加密的消息转换为BASE64消息,以便通过套接字发送该消息.
我正在尝试以下示例代码,该示例代码将"Hello World"转换为Base64格式并在控制台(stdout)中进行打印.
如何使用功能"BIO_new_fp(stdout,BIO_NOCLOSE)"将值打印到另一个字符数组而不是"stdout"?如果不是这样,我可以使用哪个Bio_函数,以便将其转换为Base64并将其放在char缓冲区中?
Hi,
I have done the RSA encryption program. Now I want to convert that encrypted message to BASE64 message inorder to send the message via socket.
I am trying the following sample code which converts "Hello World" to Base64 format and printing in console ( stdout).
How can I use the funtion "BIO_new_fp(stdout, BIO_NOCLOSE)" to print the value to another character array instead of "stdout"? If not this, which Bio_ function I can use so that it will convert to Base64 and put it in char buffer ??
#include <stdio.h>
#include <openssl/bio.h>
#include <openssl/evp.h>
int main(int argc, char *argv[])
{
printf("Hello, world\n");
BIO *bio, *b64;
char message[] = "Hello World \n";
b64 = BIO_new(BIO_f_base64());
bio = BIO_new_fp(stdout, BIO_NOCLOSE);
//bio = BIO_new_mem_buf(
bio = BIO_push(b64, bio);
BIO_write(bio, message, strlen(message));
BIO_flush(bio);
BIO_free_all(bio);
return 0;
}
[edit]代码块已移至仅覆盖代码-OriginalGriff [/edit]
[edit]Code block moved to cover code only - OriginalGriff[/edit]
推荐答案
此处为示例: [
Here an example: "Howto base64 encode with C/C++ and OpenSSL"[^].
:-)
这篇关于将RSA加密消息转换为Base64格式!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!