Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Why are there LFs in my base64? Post 302397048 by SilversleevesX on Saturday 20th of February 2010 02:34:22 PM
Old 02-20-2010
Why are there LFs in my base64?

And is there a good way of taking them out?

I've been playing around a bit with using b64 to embed images in HTML (and trying to stay within the spec). I've noticed that with openssl's base64 encoder, the output files have newline characters @ every 65th column or so. This renders them useless, at least in Firefox and SeaMonkey (where this method usually works). After pasting the base64 from the output file into an HTML document, and adding the appropriate HTML tags, instead of a visible image I get a broken thumbnail. I already know why this is, having had some user-end experience with base64 (before either Outlook or Netscape knew how to decode it on the fly). My perception, phrased as a rule-of-thumb for the benefit of some who might argue its finer points, has always been the following:
Quote:
Originally Posted by Code Gods of the 1990s
Base64 encoding must be one continuous code stream or else it is invalid.
So what happened? Did someone find an application of this particular encoding where broken streams were more useful? Or even crucial?

At any rate, a sed or awk one-liner seems appropriate here. Anyone have a good one for this situation? One to remove newline characters?

BZT.

Last edited by SilversleevesX; 02-20-2010 at 03:40 PM.. Reason: Syntax (English, not code)
 

7 More Discussions You Might Find Interesting

1. Programming

gunzip and base64 decode a string

I am writing a C program to get messages from a JMS queue into a string variable and then write them to a database. The messages are compressed (gzip) and encoded (base64), so I need to be able to perform gunzip and base64 decode inside the C. I don't want to write any of the messages to file so... (2 Replies)
Discussion started by: handak9
2 Replies

2. UNIX for Dummies Questions & Answers

I'm looking for someone who have Base64 binary

I need to install the base64 encryption method on a UNIX machine under AIX5.2. I've received a tar file but it is only C source , can you help me please. (sending me a binary base64 or to compile my source) Thanks by advance (3 Replies)
Discussion started by: Bruno_LAMOUR
3 Replies

3. UNIX for Dummies Questions & Answers

not able to run base64 exe

Hi, I have copied base64.exe under base64-1.3 folder and i am trying to run base64.exe from another folder called Request. But i am getting the following error message. mga.ksh: base64: not found Please let me know how to execute the base64.exe from a directory where it is not installed. ... (0 Replies)
Discussion started by: lotus123
0 Replies

4. UNIX for Dummies Questions & Answers

mailx saved messages are unreadable (base64)

I am trying to parse emails sent from a blackberry. I am using fetchmail to download email through IMAP from my exchange server and then forward to local Linux mail. (This part works fine.) When viewing and saving messages sent as plain text from Outlook, everything works fine. However, when... (1 Reply)
Discussion started by: Squeakygoose
1 Replies

5. BSD

LFS-like thing, but with *BSD?

Hi, do you know, is there any thing like Linux From Scratch, but for a BSD operating system? A tutorial or guide to learn (and build) the system inside out? Would be pretty cool IMO. :D Blackbird (1 Reply)
Discussion started by: Blackbird
1 Replies

6. UNIX for Beginners Questions & Answers

Ldapsearch returning base64 encoded results

So my ldapsearch works great, except for some results I found today. My search is: /usr/lib64/mozldap/ldapsearch -T -h 10.1.1.1 -p 3891 -D "uid=datapower,ou=People,dc=blah,dc=com" -w xxxxxx -b "ou=Certs,dc=blah,dc=com"... (0 Replies)
Discussion started by: primerib
0 Replies

7. Shell Programming and Scripting

Base64 conversion in awk overlaps

hi, problem: output is not consistent as expected using external command in AWK description: I'm trying to convert $2 into a base64 string for later decoding, and for this when I use awk , I'm getting overlapped results , or say it results are not 100% correct. my code is: gawk... (9 Replies)
Discussion started by: busyboy
9 Replies
BIO_f_base64(3) 						      OpenSSL							   BIO_f_base64(3)

NAME
BIO_f_base64 - base64 BIO filter SYNOPSIS
#include <openssl/bio.h> #include <openssl/evp.h> BIO_METHOD * BIO_f_base64(void); DESCRIPTION
BIO_f_base64() returns the base64 BIO method. This is a filter BIO that base64 encodes any data written through it and decodes any data read through it. Base64 BIOs do not support BIO_gets() or BIO_puts(). BIO_flush() on a base64 BIO that is being written through is used to signal that no more data is to be encoded: this is used to flush the final block through the BIO. The flag BIO_FLAGS_BASE64_NO_NL can be set with BIO_set_flags() to encode the data all on one line or expect the data to be all on one line. NOTES
Because of the format of base64 encoding the end of the encoded block cannot always be reliably determined. RETURN VALUES
BIO_f_base64() returns the base64 BIO method. EXAMPLES
Base64 encode the string "Hello World " and write the result to standard output: BIO *bio, *b64; char message[] = "Hello World "; b64 = BIO_new(BIO_f_base64()); bio = BIO_new_fp(stdout, BIO_NOCLOSE); bio = BIO_push(b64, bio); BIO_write(bio, message, strlen(message)); BIO_flush(bio); BIO_free_all(bio); Read Base64 encoded data from standard input and write the decoded data to standard output: BIO *bio, *b64, *bio_out; char inbuf[512]; int inlen; b64 = BIO_new(BIO_f_base64()); bio = BIO_new_fp(stdin, BIO_NOCLOSE); bio_out = BIO_new_fp(stdout, BIO_NOCLOSE); bio = BIO_push(b64, bio); while((inlen = BIO_read(bio, inbuf, 512)) > 0) BIO_write(bio_out, inbuf, inlen); BIO_free_all(bio); BUGS
The ambiguity of EOF in base64 encoded data can cause additional data following the base64 encoded block to be misinterpreted. There should be some way of specifying a test that the BIO can perform to reliably determine EOF (for example a MIME boundary). SEE ALSO
TBA 50 2013-03-05 BIO_f_base64(3)
All times are GMT -4. The time now is 03:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy