diff options
author | lloyd <[email protected]> | 2007-01-20 10:35:26 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2007-01-20 10:35:26 +0000 |
commit | 49922890c906296caf31ad6fa750d197b0d8db5c (patch) | |
tree | 47ba6de98bf5ab483c788ab3d5dafec8616ed707 | |
parent | 3daea9be0a02b89703a37761bad293933891d999 (diff) |
Add a new parameter to the Base64_Encoder to specify that a trailing
newline should always be added, even if the output would normally fit
entirely on the current line. Monotone needs this for compatability with
the Crypto++ implementation of base64.
-rw-r--r-- | include/base64.h | 3 | ||||
-rw-r--r-- | src/base64.cpp | 6 |
2 files changed, 5 insertions, 4 deletions
diff --git a/include/base64.h b/include/base64.h index bd3921ab8..ec144dc63 100644 --- a/include/base64.h +++ b/include/base64.h @@ -21,13 +21,14 @@ class Base64_Encoder : public Filter void write(const byte[], u32bit); void end_msg(); - Base64_Encoder(bool = false, u32bit = 72); + Base64_Encoder(bool = false, u32bit = 72, bool = false); private: void encode_and_send(const byte[], u32bit); void do_output(const byte[], u32bit); static const byte BIN_TO_BASE64[64]; const u32bit line_length; + const bool trailing_newline; SecureVector<byte> in, out; u32bit position, counter; }; diff --git a/src/base64.cpp b/src/base64.cpp index 6cfdc921e..787c7a292 100644 --- a/src/base64.cpp +++ b/src/base64.cpp @@ -12,8 +12,8 @@ namespace Botan { /************************************************* * Base64_Encoder Constructor * *************************************************/ -Base64_Encoder::Base64_Encoder(bool breaks, u32bit length) : - line_length(breaks ? length : 0) +Base64_Encoder::Base64_Encoder(bool breaks, u32bit length, bool t_n) : + line_length(breaks ? length : 0), trailing_newline(t_n) { in.create(48); out.create(4); @@ -118,7 +118,7 @@ void Base64_Encoder::end_msg() do_output(out, 4); } - if(counter && line_length) + if(trailing_newline || (counter && line_length)) send('\n'); counter = position = 0; |