Blame src/base64.mli

rpm-build 0f2925
(*
rpm-build 0f2925
 * Base64 - Base64 codec
rpm-build 0f2925
 * Copyright (C) 2003 Nicolas Cannasse
rpm-build 0f2925
 *
rpm-build 0f2925
 * This library is free software; you can redistribute it and/or
rpm-build 0f2925
 * modify it under the terms of the GNU Lesser General Public
rpm-build 0f2925
 * License as published by the Free Software Foundation; either
rpm-build 0f2925
 * version 2.1 of the License, or (at your option) any later version,
rpm-build 0f2925
 * with the special exception on linking described in file LICENSE.
rpm-build 0f2925
 *
rpm-build 0f2925
 * This library is distributed in the hope that it will be useful,
rpm-build 0f2925
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 0f2925
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build 0f2925
 * Lesser General Public License for more details.
rpm-build 0f2925
 *
rpm-build 0f2925
 * You should have received a copy of the GNU Lesser General Public
rpm-build 0f2925
 * License along with this library; if not, write to the Free Software
rpm-build 0f2925
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
rpm-build 0f2925
 *)
rpm-build 0f2925
rpm-build 0f2925
(** Base64 codec.
rpm-build 0f2925
rpm-build 0f2925
  8-bit characters are encoded into 6-bit ones using ASCII lookup tables.
rpm-build 0f2925
  Default tables maps 0..63 values on characters A-Z, a-z, 0-9, '+' and '/'
rpm-build 0f2925
  (in that order). 
rpm-build 0f2925
*)
rpm-build 0f2925
rpm-build 0f2925
open ExtBytes
rpm-build 0f2925
rpm-build 0f2925
(** This exception is raised when reading an invalid character
rpm-build 0f2925
  from a base64 input. *)
rpm-build 0f2925
exception Invalid_char
rpm-build 0f2925
rpm-build 0f2925
(** This exception is raised if the encoding or decoding table
rpm-build 0f2925
  size is not correct. *)
rpm-build 0f2925
exception Invalid_table
rpm-build 0f2925
rpm-build 0f2925
(** An encoding table maps integers 0..63 to the corresponding char. *)
rpm-build 0f2925
type encoding_table = char array
rpm-build 0f2925
rpm-build 0f2925
(** A decoding table maps chars 0..255 to the corresponding 0..63 value
rpm-build 0f2925
 or -1 if the char is not accepted. *)
rpm-build 0f2925
type decoding_table = int array
rpm-build 0f2925
rpm-build 0f2925
(** erroneous interface, kept for compatibility use [encode_string] instead *)
rpm-build 0f2925
val str_encode : ?tbl:encoding_table -> string -> Bytes.t
rpm-build 0f2925
rpm-build 0f2925
(** erroneous interface, kept for compatibility use [decode_string] instead *)
rpm-build 0f2925
val str_decode : ?tbl:decoding_table -> Bytes.t -> string
rpm-build 0f2925
rpm-build 0f2925
(** Encode a string into Base64. *)
rpm-build 0f2925
val encode_string : ?tbl:encoding_table -> string -> string
rpm-build 0f2925
rpm-build 0f2925
(** Decode a string encoded into Base64, raise [Invalid_char] if a
rpm-build 0f2925
  character in the input string is not a valid one. *)
rpm-build 0f2925
val decode_string : ?tbl:decoding_table -> string -> string
rpm-build 0f2925
rpm-build 0f2925
(** Generic base64 encoding over an output. *)
rpm-build 0f2925
val encode : ?tbl:encoding_table -> 'a IO.output -> 'a IO.output
rpm-build 0f2925
rpm-build 0f2925
(** Generic base64 decoding over an input. *)
rpm-build 0f2925
val decode : ?tbl:decoding_table -> IO.input -> IO.input
rpm-build 0f2925
rpm-build 0f2925
(** Create a valid decoding table from an encoding one. *)
rpm-build 0f2925
val make_decoding_table : encoding_table -> decoding_table