Skip to content

Commit

Permalink
Fixed bug 897.
Browse files Browse the repository at this point in the history
  • Loading branch information
sfindeisen committed Jun 23, 2011
1 parent 5c6cc89 commit 04f8a48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cryptokit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ module Base64 = struct
let base64_conv_table =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

class encode multiline =
class encode multiline padding =
object (self)
method input_block_size = 1
method output_block_size = 1
Expand Down Expand Up @@ -1889,7 +1889,7 @@ class encode multiline =
oend <- oend + 3
| _ -> ()
end;
if multiline then begin
if multiline or padding then begin
let num_equals =
match ipos with 1 -> 2 | 2 -> 1 | _ -> 0 in
self#ensure_capacity num_equals;
Expand All @@ -1907,8 +1907,9 @@ class encode multiline =
wipe_string ibuf; output_buffer#wipe
end

let encode_multiline () = new encode true
let encode_compact () = new encode false
let encode_multiline () = new encode true true
let encode_compact () = new encode false false
let encode_compact_pad () = new encode false true

let base64_decode_char c =
match c with
Expand Down
3 changes: 3 additions & 0 deletions src/cryptokit.mli
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,9 @@ module Base64: sig
split into lines, and no final padding is added.
This is adequate for encoding short strings for
transmission as part of URLs, for instance. *)
val encode_compact_pad : unit -> transform
(** Same as {!Cryptokit.Base64.encode_compact}, but the output is
padded with [=] characters at the end (if necessary). *)
val decode : unit -> transform
(** Return a transform that performs base 64 decoding.
The input must consist of valid base 64 characters;
Expand Down

0 comments on commit 04f8a48

Please sign in to comment.