OffTopic: Base64 over HTTPS
Hi: I am having trouble sending Base64 data over HTTPS POST. Does anybody have any sample code that can encode the Base64 to remove the reserved characters so that HTTP POST is possible cheers Mohan Atreya _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
Re: OffTopic: Base64 over HTTPS
hope this helps. i don't remember where i found it... any way, here you are. #include stdio.h #include base64.h unsigned char alphabet[64] = ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/; int base64_decode(unsigned char *outbuf, unsigned char *inbuf, int size) { static unsigned char inalphabet[256], decoder[256]; int j, i, bits, c, char_count, errors = 0; for (i = (sizeof alphabet) - 1; i = 0 ; i--) { inalphabet[alphabet[i]] = 1; decoder[alphabet[i]] = i; } char_count = 0; bits = 0; i = 0; j = 0; while (isize) { c = inbuf[i++]; if (c == '=') break; if (c 255 || ! inalphabet[c]) continue; bits += decoder[c]; char_count++; if (char_count == 4) { outbuf[j++] = bits 16; outbuf[j++] = (bits 8) 0xff; outbuf[j++] = bits 0xff; bits = 0; char_count = 0; } else { bits = 6; } } if (c == EOF) { if (char_count) errors++; } else { /* c == '=' */ switch (char_count) { case 1: errors++; break; case 2: outbuf[j++] = bits 10; break; case 3: outbuf[j++] = bits 16; outbuf[j++] = (bits 8) 0xff; break; } } return (errors ? 0 : j); } int base64_encode(unsigned char *outbuf, unsigned char *inbuf, int size) { int i, j, cols, bits, c, char_count; char_count = 0; bits = 0; cols = 0; i = 0; j = 0; while (isize) { c = inbuf[i++]; bits += c; char_count++; if (char_count == 3) { outbuf[j++] = alphabet[bits 18]; outbuf[j++] = alphabet[(bits 12) 0x3f]; outbuf[j++] = alphabet[(bits 6) 0x3f]; outbuf[j++] = alphabet[bits 0x3f]; cols += 4; if (cols == 72) { outbuf[j++] = '\n'; cols = 0; } bits = 0; char_count = 0; } else { bits = 8; } } if (char_count != 0) { bits = 16 - (8 * char_count); outbuf[j++] = alphabet[bits 18]; outbuf[j++] = alphabet[(bits 12) 0x3f]; if (char_count == 1) { outbuf[j++] = '='; outbuf[j++] = '='; } else { outbuf[j++] = alphabet[(bits 6) 0x3f]; outbuf[j++] = '='; } if (cols 0) outbuf[j++] = '\n'; } return j; }
Re: OffTopic: Base64 over HTTPS
i forgot to say that i use the code i send you in https posts. aleix __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
Re: OffTopic: Base64 over HTTPS
on 1/30/02 7:03 AM, [EMAIL PROTECTED] purportedly said: I am having trouble sending Base64 data over HTTPS POST. Does anybody have any sample code that can encode the Base64 to remove the reserved characters so that HTTP POST is possible What's the problem you are having? As far as I know, there are no restrictions on the data portion of a post request. Since SSL is basically a tunneling protocol, it does not impact the content of HTTP messages. Keary Suska Esoteritech, Inc. Leveraging Open Source for a better Internet __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]
RE: OffTopic: Base64 over HTTPS
There shouldn't be any problems sending Base64 data over HTTP. HTTP doesn't care what the content-body data looks like (with the exception of the optional length header for the Chunked transfer-encoding). Is the problem that you're sending Base64 data as part of an HTML document over HTTP? Michael Wojcik402 438-7842 Software Systems DeveloperMicro Focus From: Mohan Atreya [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 30, 2002 8:03 AM I am having trouble sending Base64 data over HTTPS POST. Does anybody have any sample code that can encode the Base64 to remove the reserved characters so that HTTP POST is possible cheers Mohan Atreya __ OpenSSL Project http://www.openssl.org User Support Mailing List[EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]