您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BIO_f_base64函数代码示例

51自学网 2021-06-01 19:49:59
  C++
这篇教程C++ BIO_f_base64函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BIO_f_base64函数的典型用法代码示例。如果您正苦于以下问题:C++ BIO_f_base64函数的具体用法?C++ BIO_f_base64怎么用?C++ BIO_f_base64使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BIO_f_base64函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

intmain(int argc, char** argv){    // get data to encrypt.      //    if (argc != 3) {        printf("Usage: %s <base64 enc key> <data to encryt>/n",                argv[0]);        return 0;    }    // base64 decode key    //    BIO *mbio = BIO_new_mem_buf(argv[1], strlen(argv[1]));    BIO *b64bio = BIO_new(BIO_f_base64());    BIO_set_flags(b64bio, BIO_FLAGS_BASE64_NO_NL);    BIO *bio = BIO_push(b64bio, mbio);    char key[256];    size_t keylen = 0;    keylen = BIO_read(bio, key, sizeof(key));    BIO_free(mbio);    BIO_free(b64bio);    // encrypt the data    //    char out[256];    int outlen = 0;    EVP_CIPHER_CTX ctx;    EVP_EncryptInit(&ctx, EVP_aes_256_ecb(), key, NULL);    EVP_EncryptUpdate(&ctx, out, &outlen, argv[2], strlen(argv[2]));    EVP_EncryptFinal(&ctx, out, &outlen);    EVP_CIPHER_CTX_cleanup(&ctx);    // base64 encode encrypted data    //    mbio = BIO_new(BIO_s_mem());    b64bio = BIO_new(BIO_f_base64());    BIO_set_flags(b64bio, BIO_FLAGS_BASE64_NO_NL);    bio = BIO_push(b64bio, mbio);    BIO_write(bio, out, outlen);    BIO_flush(bio);    char* data = NULL;    size_t datalen = 0;    datalen = BIO_get_mem_data(mbio, &data);    data[datalen] = '/0';    printf("encrypted data: [%s]/n", data);    BIO_free(mbio);    BIO_free(b64bio);    return 0;}
开发者ID:pp7462-git,项目名称:sandbox,代码行数:57,


示例2: BIO_new

char *base64_enc(const char *str, int len){	BIO *bio, *b64;	BUF_MEM *bptr;	char *buf;	int ret;	b64 = BIO_new(BIO_f_base64());	bio = BIO_new(BIO_s_mem());	b64 = BIO_push(b64, bio);	ret = BIO_write(b64, str, len);	if (ret <= 0) {		buf = NULL;		goto err;	}	BIO_flush(b64);	BIO_get_mem_ptr(b64, &bptr);	buf = malloc(bptr->length);	if (buf) {		memcpy(buf, bptr->data, bptr->length-1);		buf[bptr->length - 1] = 0;	}err:	BIO_free_all(b64);	return buf;}
开发者ID:ionutradu,项目名称:mailfilter,代码行数:30,


示例3: s3_base64_encode

gchar*s3_base64_encode(const GByteArray *to_enc) {    BIO *bio_b64 = NULL, *bio_buff = NULL;    long bio_b64_len;    char *bio_b64_data = NULL, *ret = NULL;    if (!to_enc) return NULL;    /* Initialize base64 encoding filter */    bio_b64 = BIO_new(BIO_f_base64());    g_assert(bio_b64);    BIO_set_flags(bio_b64, BIO_FLAGS_BASE64_NO_NL);    /* Initialize memory buffer for the base64 encoding */    bio_buff = BIO_new(BIO_s_mem());    g_assert(bio_buff);    bio_buff = BIO_push(bio_b64, bio_buff);    /* Write the MD5 hash into the buffer to encode it in base64 */    BIO_write(bio_buff, to_enc->data, to_enc->len);    /* BIO_flush is a macro and GCC 4.1.2 complains without this cast*/    (void) BIO_flush(bio_buff);    /* Pull out the base64 encoding of the MD5 hash */    bio_b64_len = BIO_get_mem_data(bio_buff, &bio_b64_data);    g_assert(bio_b64_data);    ret = g_strndup(bio_b64_data, bio_b64_len);    /* If bio_b64 is freed separately, freeing bio_buff will     * invalidly free memory and potentially segfault.     */    BIO_free_all(bio_buff);    return ret;}
开发者ID:TonyChiang,项目名称:amanda,代码行数:33,


示例4: BIO_new

	char *base64(const unsigned char *input, int length)	{		BIO *bmem, *b64;		BUF_MEM *bptr;		b64 = BIO_new(BIO_f_base64());		BIO_set_flags(b64,BIO_FLAGS_BASE64_NO_NL);		bmem = BIO_new(BIO_s_mem());		b64 = BIO_push(b64, bmem);		BIO_write(b64, magic, sizeof(magic)-1);		BIO_write(b64, (char*)salt, sizeof(salt));		BIO_write(b64, input, length);		BIO_flush(b64);		BIO_get_mem_ptr(b64, &bptr);		char *buff = (char *)malloc(bptr->length);//		memcpy(buff, bptr->data, bptr->length-1);		int chars = 0;		for (unsigned int i = 0; i < bptr->length-1; i++) {			if (bptr->data[i] == '+') { buff[chars] = '-'; chars++;}			else if (bptr->data[i] == '/') { buff[chars] = '_'; chars++; }			else if (bptr->data[i] != '=') { buff[chars] = bptr->data[i]; chars++; }		}		buff[chars] = 0;				BIO_free_all(b64);		return buff;	}
开发者ID:asturel,项目名称:znc_modules,代码行数:34,


示例5: we

/**	b64decode	Decodes a base64-encoded message.  You provide an encoded message,	and a pointer to somewhere we (the editorial we) can store the length 	of the decoded message.  A dynamically allocated pointer is returned.*/char *b64decode(char *encoded, size_t *newlen){        BIO     *b64, *bmem;        char    *decoded = NULL;	if(encoded == NULL) {		print_loc(); io_debug("NULL data passed!  Bad coder!  Bad!/n");		return NULL;	}	safe_malloc(decoded,*newlen);        b64 = BIO_new(BIO_f_base64());        bmem = BIO_new_mem_buf(encoded, -1);	if(bmem == NULL || b64 == NULL) {		print_loc(); io_debug("Calls to libssl failed!/n");		abort();  //I don't think this will ever happen.	}        bmem = BIO_push(b64, bmem);        *newlen = BIO_read(bmem, decoded, *newlen);	BIO_free_all(bmem);	decoded[*newlen] = '/0';	return decoded;}
开发者ID:pete,项目名称:freenote-probe,代码行数:33,


示例6: decodeBase64

char* decodeBase64(unsigned char *input, size_t length, size_t *out_length) {  BIO *b64, *bmem;  size_t decodedLen;  char *buffer = (char*)NFCD_MALLOC(length+1);  if (buffer == NULL) {    return NULL;  }  memset(buffer, 0, length);  b64 = BIO_new(BIO_f_base64());  if (b64 == NULL) {    return NULL;  }  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);  bmem = BIO_new_mem_buf(input, length);  bmem = BIO_push(b64, bmem);  decodedLen = BIO_read(bmem, buffer, length);  buffer[decodedLen] = 0;  *out_length = decodedLen;  BIO_free_all(bmem);  return buffer;}
开发者ID:svic,项目名称:b2g-nfcd,代码行数:25,


示例7: base64Decode

static Buffer::Ptr base64Decode(T t) {    if (!t) return Buffer::null();    if (!t->length()) return Buffer::create();    std::string src = t->toStdString();    Size len = src.length();    if (len != t->length()) return Buffer::null();    BIO* bio = BIO_new(BIO_f_base64());    BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);    BIO* bioMem = BIO_new_mem_buf(const_cast<char*>(src.c_str()), len);    bio = BIO_push(bio, bioMem);    char* dst = new char[len + 1];    int readLen = BIO_read(bio, dst, len);    Buffer::Ptr decoded;    if (readLen > 0) {        decoded = Buffer::create(dst, readLen);    } else {        decoded = Buffer::null();    }    BIO_free_all(bio);    delete[] dst;    return decoded;}
开发者ID:LittoCats,项目名称:libnode,代码行数:25,


示例8: write_b64

int write_b64( const char *filename, unsigned char *out, int len ){    int count;    BIO *b64, *file;    /* Create a buffered file BIO for writing */    file = BIO_new_file (filename, "w");    if (!file) {        /* FIXME - log an error */        return -1;    }    /* Create a base64 encoding filter BIO */    b64 = BIO_new (BIO_f_base64 ());    assert( b64 != NULL );    if( b64 == NULL ) {        /* FIXME - log an error */        return -1;    }    /* Assemble the BIO chain to be in the order b64-file */    BIO_push (b64, file );    count = write_to_BIO( b64, out, len );    assert( count == len );    BIO_free_all( b64 );    /* success */    return count;}
开发者ID:linuxlizard,项目名称:snmptree,代码行数:31,


示例9: clevis_buf_encode

json_t *clevis_buf_encode(const clevis_buf_t *buf){  json_t *out = NULL;  BIO *mem = NULL;  BIO *b64 = NULL;  char *c = NULL;  int r = 0;  mem = BIO_new(BIO_s_mem());  if (!mem)    goto egress;  b64 = BIO_new(BIO_f_base64());  if (!b64)    goto egress;  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);  if (!BIO_push(b64, mem))    goto egress;  r = BIO_write(b64, buf->buf, buf->len);  if (r != (int) buf->len)    goto egress;  BIO_flush(b64);  r = BIO_get_mem_data(mem, &c);  out = json_stringn(c, r);egress:  BIO_free(b64);  BIO_free(mem);  return out;}
开发者ID:ep69,项目名称:clevis,代码行数:35,


示例10: base64Encode

static int base64Encode(char* output, const unsigned char* data, size_t length){    BIO* base64 = BIO_new(BIO_f_base64());    if (base64 == NULL) {        return -1;    }    BIO_set_flags(base64, BIO_FLAGS_BASE64_NO_NL);    BIO* memory = BIO_new(BIO_s_mem());    if (memory == NULL) {        BIO_free_all(base64);        return -1;    }    BIO* bio = BIO_push(base64, memory);    BIO_write(bio, data, length);    if (BIO_flush(bio) == -1) {        return -1;    }    const char* p;    size_t n = BIO_get_mem_data(memory, &p);    int i;    for (i = 0; i < n; ++i) {        if (*(p+i) == '+') {            *(output+i) = '-';        } else if (*(p+i) == '/') {            *(output+i) = '_';        } else if (*(p+i) == '=') {            break;        } else {            *(output+i) = *(p+i);        }    }    BIO_free_all(bio);    return n;}
开发者ID:houzhenggang,项目名称:mt7688_mips_ecos,代码行数:35,


示例11: unbase64

static size_t unbase64(const char *bytes, char **unbase64){	size_t len;	BIO *memory, *b64;	char *buffer;	len = strlen(bytes);	if (!len)		goto error;	b64 = BIO_new(BIO_f_base64());	memory = BIO_new_mem_buf((char *)bytes, len);	if (!b64 || !memory)		goto error;	b64 = BIO_push(b64, memory);	if (!b64)		goto error;	BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);	buffer = xcalloc(len + 1, 1);	len = BIO_read(b64, buffer, len);	if ((int)len <= 0)		goto error;	buffer[len] = '/0';	BIO_free_all(b64);	*unbase64 = buffer;	return len;error:	die("Could not unbase64 the given bytes.");}
开发者ID:TonyAbell,项目名称:lastpass-cli,代码行数:30,


示例12: BIO_new

static char *base64(const char *bytes, size_t len){	BIO *memory, *b64;	BUF_MEM *buffer;	char *output;	b64 = BIO_new(BIO_f_base64());	BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);	memory = BIO_new(BIO_s_mem());	if (!b64 || !memory)		goto error;	b64 = BIO_push(b64, memory);	if (!b64)		goto error;	if (BIO_write(b64, bytes, len) < 0 || BIO_flush(b64) < 0)		goto error;	BIO_get_mem_ptr(b64, &buffer);	output = xmalloc(buffer->length + 1);	memcpy(output, buffer->data, buffer->length);	output[buffer->length] = '/0';	BIO_free_all(b64);	return output;error:	die("Could not base64 the given bytes.");}
开发者ID:TonyAbell,项目名称:lastpass-cli,代码行数:28,


示例13: base64_encode

/* * des - base64编码,将二进制字符与64个可打印字符进行对应转化。 2^6 = 64,6bits对应一个字符,三个字节对应四个可见字符 * param - str : 需编码的数据 *		   str_len : str的长度 *		   encode : 编码后数据存储 *		   encode_len : encode缓冲区的长度,要求大小需大于str_len,建议为(str_len/3) * 4 + 8 * ret - success : 编码后数据实际长度 * 		 fail : -1 */int base64_encode(char *str,int str_len,char *encode, u_int encode_len){	BIO *bmem,*b64;	BUF_MEM *bptr;	b64=BIO_new(BIO_f_base64());	BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);	bmem=BIO_new(BIO_s_mem());	b64=BIO_push(b64, bmem);	BIO_write(b64, str, str_len); //encode	BIO_flush(b64);	BIO_get_mem_ptr(b64,&bptr);//	printf("%d/n", bptr->length);	if(bptr->length > encode_len){		 printf("encode_len too small/n");		 return -1; 	}   	encode_len=bptr->length;	memcpy(encode,bptr->data,bptr->length);	encode[bptr->length] = '/0';	BIO_free_all(b64);	return encode_len;}
开发者ID:misslio,项目名称:lctools,代码行数:37,


示例14: decodeBase64

gchar* decodeBase64(gchar *data, gint length, gint *actualLength) {    gchar *input = data;    gint correctedLength = getCorrectedEncodeSize(length);    if(length != correctedLength) {        input = g_malloc(correctedLength * sizeof(gchar));        memset(input, 0, correctedLength);        memcpy(input, data, length);        memset(input + length, '=', correctedLength - length);    }    gchar *buffer = g_malloc(correctedLength);    memset(buffer, 0, correctedLength);    BIO *b64 = BIO_new(BIO_f_base64());    BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);    BIO *bmem = BIO_new_mem_buf(input, correctedLength);    BIO_set_flags(bmem, BIO_FLAGS_BASE64_NO_NL);    bmem = BIO_push(b64, bmem);    BIO_set_flags(bmem, BIO_FLAGS_BASE64_NO_NL);    *actualLength = BIO_read(bmem, buffer, correctedLength);    BIO_free_all(bmem);    if(length != correctedLength) {        g_free(input);    }    return buffer;}
开发者ID:houzhenggang,项目名称:openwrt-ar9331,代码行数:30,


示例15: memset

char *base64_dec(char *str, int len, int *result_len){	BIO *bio, *b64;	char *buf;	int ret;	if (!(buf = malloc(len)))		return NULL;	memset(buf, 0, len);	b64 = BIO_new(BIO_f_base64());	bio = BIO_new_mem_buf(str, len);	bio = BIO_push(b64, bio);	ret = BIO_read(bio, buf, len);	if (ret <= 0) {		free(buf);		buf = NULL;	}	BIO_free_all(bio);	if (result_len)		*result_len = ret;	return buf;}
开发者ID:ionutradu,项目名称:mailfilter,代码行数:27,


示例16: malloc

/* caller must free the returned string */char *base64_dec(unsigned char *in, int size){  BIO *bio64, *biomem;  char *buf=NULL;  buf = malloc(sizeof(char) * size);  bzero(buf, size);  if ((bio64 = BIO_new(BIO_f_base64())) == NULL) {    logprintfl(EUCAERROR, "BIO_new(BIO_f_base64()) failed/n");  } else {    BIO_set_flags (bio64, BIO_FLAGS_BASE64_NO_NL); /* no long-line wrapping */    if ((biomem = BIO_new_mem_buf(in, size)) == NULL) {      logprintfl(EUCAERROR, "BIO_new_mem_buf() failed/n");    } else {      biomem = BIO_push(bio64, biomem);      if ((BIO_read(biomem, buf, size)) <= 0) {        logprintfl(EUCAERROR, "BIO_read() read failed/n");      }      //      BIO_free_all(biomem);    }    BIO_free_all(bio64);  }  return buf;}
开发者ID:chrkl,项目名称:eucalyptus,代码行数:29,


示例17: alloc_cipher_BIOs

int alloc_cipher_BIOs( BIO **buffer, BIO **b64, BIO **cipher ){    *buffer = *b64 = *cipher = NULL;     /* Create a buffering filter BIO to buffer writes to the file */    *buffer = BIO_new (BIO_f_buffer ());    if( buffer == NULL ) {        return -1;    }    /* Create a base64 encoding filter BIO */    *b64 = BIO_new (BIO_f_base64 ());    if( *b64 == NULL ) {        BIO_free( *buffer );        *buffer = NULL;        return -1;    }        *cipher = BIO_new (BIO_f_cipher ());    if( *cipher == NULL ) {        BIO_free( *buffer );        BIO_free( *b64 );        *buffer = *b64 = NULL;        return -1;    }    /* success */    return 0;}
开发者ID:linuxlizard,项目名称:snmptree,代码行数:29,


示例18: BIO_new

char *EstEID_base64Encode(const char *input, int length) {	BIO *memBio;	BIO *b64Bio;	char *b;	int len;	char *result;	LOG_LOCATION;	memBio = BIO_new(BIO_s_mem());	b64Bio = BIO_new(BIO_f_base64());	b64Bio = BIO_push(b64Bio, memBio);	BIO_write(b64Bio, input, length);	(void)BIO_flush(b64Bio);	len = BIO_get_mem_data(memBio, &b);	result = (char *)malloc(len + 1);	strncpy(result, b, len);	result[len] = 0;	BIO_free_all(b64Bio);	while (result[--len] == '/n') result[len] = 0;	return result;}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:25,


示例19: read_b64

int read_b64( const char *filename, unsigned char *out, int len ){    int count;    BIO *b64, *buffer, *file;    /* Create a buffered file BIO for reading */    file = BIO_new_file (filename, "r");    if (!file) {        /* FIXME - log an error */        return -1;    }    /* Create a base64 encoding filter BIO */    b64 = BIO_new (BIO_f_base64 ());    if( b64 == NULL ) {        /* FIXME - log an error */        return -1;    }    buffer = BIO_new (BIO_f_buffer ());    /* Assemble the BIO chain to be in the order b64-file */    BIO_push (b64, buffer );    BIO_push( buffer, file );    /* load the data */    count = read_from_BIO( b64, out, len );    assert( count == len );    BIO_free_all( b64 );    /* success */    return count;}
开发者ID:linuxlizard,项目名称:snmptree,代码行数:34,


示例20: BIO_new

/* * Base64 encode a buffer passed in. Return a talloc allocated string. */static char *base64_enc(void *ctx, 			const char *buf,			size_t size){	BIO *b64_filter = BIO_new(BIO_f_base64());	BIO *mem_ssink  = BIO_new(BIO_s_mem());	BUF_MEM *bio_mem = NULL;	int ret = 0;	char *ret_str;	b64_filter = BIO_push(b64_filter, mem_ssink);	ret = BIO_write(b64_filter, buf, size);	if (ret < 0 || ret != size) {		DEBUG(0, ("Unable to write all data to b64_filter: %s/n",			strerror(errno)));	}	ret = BIO_flush(b64_filter);	BIO_get_mem_ptr(b64_filter, &bio_mem);	/* This should append a terminating null to turn it into a string */	ret_str = talloc_strndup(ctx, bio_mem->data, bio_mem->length);	BIO_free_all(b64_filter);	return ret_str;}
开发者ID:RichardSharpe,项目名称:Amazon-S3-VFS,代码行数:30,


示例21: encodeBase64

char* encodeBase64(const char *input, size_t length){  if(length > 0) {    BIO *bmem, *b64;    BUF_MEM *bptr;    b64 = BIO_new(BIO_f_base64());    BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);    bmem = BIO_new(BIO_s_mem());    b64 = BIO_push(b64, bmem);    BIO_write(b64, input, length);    BIO_flush(b64);    BIO_get_mem_ptr(b64, &bptr);    char *buff = (char *)NFCD_MALLOC(bptr->length+1);    memcpy(buff, bptr->data, bptr->length);    buff[bptr->length] = 0;     BIO_free_all(b64);    return buff;  } else {    return "";  }}
开发者ID:svic,项目名称:b2g-nfcd,代码行数:25,


示例22: strlen

uint8_t *base64_dec(char *input, int *outlen) {  BIO *bmem, *b64;  int inlen = strlen(input);  b64 = BIO_new(BIO_f_base64());  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);  bmem = BIO_new(BIO_s_mem());  b64 = BIO_push(b64, bmem);  // Apple cut the padding off their challenges; restore it  BIO_write(bmem, input, inlen);  while (inlen++ & 3)    BIO_write(bmem, "=", 1);  BIO_flush(bmem);  int bufsize = strlen(input) * 3 / 4 + 1;  uint8_t *buf = malloc(bufsize);  int nread;  nread = BIO_read(b64, buf, bufsize);  BIO_free_all(bmem);  *outlen = nread;  return buf;}
开发者ID:Havelock-Vetinari,项目名称:shairport-sync,代码行数:26,


示例23: assert

char *StringEncodeBase64(const char *str, size_t len){    assert(str);    if (!str)    {        return NULL;    }    if (len == 0)    {        return xcalloc(1, sizeof(char));    }    BIO *b64 = BIO_new(BIO_f_base64());    BIO *bio = BIO_new(BIO_s_mem());    b64 = BIO_push(b64, bio);    BIO_write(b64, str, len);    if (!BIO_flush(b64))    {        assert(false && "Unable to encode string to base64" && str);        return NULL;    }    BUF_MEM *buffer = NULL;    BIO_get_mem_ptr(b64, &buffer);    char *out = xcalloc(1, buffer->length);    memcpy(out, buffer->data, buffer->length - 1);    out[buffer->length - 1] = '/0';    BIO_free_all(b64);    return out;}
开发者ID:dardevelin,项目名称:core-1,代码行数:33,


示例24: rd_base64_decode

/** * @brief Base64 decode input string /p in of size /p insize. * @returns -1 on invalid Base64, or 0 on successes in which case a *         newly allocated binary string is set in out (and size). */static int rd_base64_decode (const rd_chariov_t *in, rd_chariov_t *out) {        size_t asize;        BIO *b64, *bmem;        if (in->size == 0 || (in->size % 4) != 0)                return -1;        asize = (in->size * 3) / 4; /* allocation size */        out->ptr = rd_malloc(asize+1);        b64 = BIO_new(BIO_f_base64());        BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);        bmem = BIO_new_mem_buf(in->ptr, (int)in->size);        bmem = BIO_push(b64, bmem);        out->size = BIO_read(bmem, out->ptr, (int)asize+1);        assert(out->size <= asize);        BIO_free_all(bmem);#if ENABLE_DEVEL        /* Verify that decode==encode */        {                char *encoded = rd_base64_encode(out);                assert(strlen(encoded) == in->size);                assert(!strncmp(encoded, in->ptr, in->size));                rd_free(encoded);        }#endif        return 0;}
开发者ID:eugpermar,项目名称:librdkafka,代码行数:37,


示例25: BIO_new

/**	b64encode	Encodes raw data in base64.  Pass the data and the length of the data.	b64encode returns the base64-encoded data as a dynamically allocated 	char *.*/char *b64encode(char *data, size_t datalen){	BIO	*b64, *bmem;	BUF_MEM	*bptr;	char	*encoded = NULL;	        b64 = BIO_new(BIO_f_base64());        bmem = BIO_new(BIO_s_mem());	if(bmem == NULL || b64 == NULL) {		print_loc(); io_debug("Calls to libssl failed!/n");		abort();  //I don't think this will ever happen.	}        bmem = BIO_push(b64, bmem);        BIO_write(bmem, data, datalen);        BIO_flush(bmem);        BIO_get_mem_ptr(bmem, &bptr);        BIO_set_close(bmem, BIO_NOCLOSE);	safe_malloc(encoded, bptr->length);	memcpy(encoded, bptr->data, bptr->length);	encoded[bptr->length] = '/0';	BIO_free_all(bmem);	BUF_MEM_free(bptr);	return encoded;}
开发者ID:pete,项目名称:freenote-probe,代码行数:37,


示例26: OT_base64_decode

uint8_t* OT_base64_decode(const char *input, size_t* out_len, int bLineBreaks){    BIO *bmem = NULL, *b64 = NULL;		OT_ASSERT(NULL != input);	    int in_len = strlen(input);    int out_max_len=(in_len*6+7)/8;    unsigned char *buf = new unsigned char [out_max_len];		OT_ASSERT(NULL != buf);		memset(buf, 0, out_max_len);	b64 = BIO_new(BIO_f_base64());		if (b64) 	{		if (!bLineBreaks) 		{			BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);		}		bmem = BIO_new_mem_buf((char*)input, in_len);		b64 = BIO_push(b64, bmem);		*out_len = BIO_read(b64, buf, out_max_len);		BIO_free_all(b64);	}	else 	{		OT_ASSERT_MSG(false, "Failed creating new Bio in base64_decode./n");	}    return buf;}
开发者ID:DOUGLASMENDES,项目名称:Open-Transactions,代码行数:34,


示例27: fillSeedSIV

int fillSeedSIV(void *siv, size_t sivSize, void *content, size_t contentLength, size_t start){	int read = 0, i;	void *skip = NULL;	BIO *b64 = NULL, *bio = BIO_new_mem_buf(content, contentLength);	if(bio == NULL) goto fill_end;	b64 = BIO_new(BIO_f_base64());	bio = BIO_push(b64, bio);	if(start != 0)	{		skip = malloc(start);		read = BIO_read(bio, skip, start);		if(read != start)		{			read = 0;			goto fill_end;		}	}	read = BIO_read(bio, siv, sivSize);	for(i = 0; i < read; ++i)	{		if((((unsigned char*)siv)[i] & 0xf0) == 0)			((unsigned char*)siv)[i] |= 0x30;	}fill_end:	if(skip != NULL) free(skip);	if(bio != NULL) BIO_free_all(bio);	return read;}
开发者ID:fvpolpeta,项目名称:simple-ris,代码行数:30,


示例28: Impl

 Impl()   : m_base64(BIO_new(BIO_f_base64()))   , m_sink(BIO_new(BIO_s_mem())) {   // connect base64 transform to the data sink.   BIO_push(m_base64, m_sink); }
开发者ID:cawka,项目名称:ndn-cxx,代码行数:7,


示例29: BIO_new

char *PICA_id_to_base64(const unsigned char *id, char *buf){	BIO *biomem, *b64;	static char localbuf[PICA_ID_SIZE * 2];	char *sourcebuf, *outputbuf = buf;	long b64len;	b64 = BIO_new(BIO_f_base64());	biomem = BIO_new(BIO_s_mem());	biomem = BIO_push(b64, biomem);	BIO_write(biomem, id, PICA_ID_SIZE);	BIO_flush(biomem);	b64len = BIO_get_mem_data(biomem, &sourcebuf);	if (outputbuf == NULL)		outputbuf = localbuf;	memcpy(outputbuf, sourcebuf, b64len);	*strchr(outputbuf, '/n') = '/0';	outputbuf[b64len] = '/0';	BIO_free_all(biomem);	return outputbuf;}
开发者ID:antonsviridenko,项目名称:pica-pica,代码行数:28,


示例30: base64_enc

/* caller must free the returned string */char * base64_enc (unsigned char * in, int size){  char * out_str = NULL;  BIO * biomem, * bio64;    if ( (bio64 = BIO_new (BIO_f_base64 ())) == NULL) {    logprintfl (EUCAERROR, "error: BIO_new(BIO_f_base64()) failed/n");  } else {    BIO_set_flags (bio64, BIO_FLAGS_BASE64_NO_NL); /* no long-line wrapping */    if ( (biomem = BIO_new (BIO_s_mem ())) == NULL) {      logprintfl (EUCAERROR, "error: BIO_new(BIO_s_mem()) failed/n");    } else {      bio64 = BIO_push (bio64, biomem);      if ( BIO_write (bio64, in, size)!=size) {	logprintfl (EUCAERROR, "error: BIO_write() failed/n");      } else {	BUF_MEM * buf;	(void) BIO_flush (bio64);	BIO_get_mem_ptr (bio64, &buf);	if ( (out_str = malloc(buf->length+1)) == NULL ) {	  logprintfl (EUCAERROR, "error: out of memory for Base64 buf/n");	} else {	  memcpy (out_str, buf->data, buf->length);	  out_str [buf->length] = '/0';	}      }    }    BIO_free_all (bio64); /* frees both bio64 and biomem */  }  return out_str;}
开发者ID:chrkl,项目名称:eucalyptus,代码行数:32,



注:本文中的BIO_f_base64函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ BIO_free函数代码示例
C++ BIO_dgram_is_sctp函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。