BeFoR64, Base64 encoding/decoding library for FoRtran poor people.
-brightgreen.svg)
-brightgreen.svg)
Modern Fortran standards (2003+) have introduced better support for strings manipulations. Exploiting such new Fortran capabilities, BeFoR64 provides an easy to use module library for encoding and decoding Fortran types (binary internal representation) in ascii-base64-encoded string.
Go to Top
Any feature request is welcome.
Go to Top
BeFoR64 is an open source project, it is distributed under a multi-licensing system:
Anyone is interest to use, to develop or to contribute to BeFoR64 is welcome, feel free to select the license that best matches your soul!
More details can be found on wiki.
Go to Top
Besides this README file the BeFoR64 documentation is contained into its own wiki. Detailed documentation of the API is contained into the GitHub Pages that can also be created locally by means of ford tool.
Let us assume our goal is encoding a binary integer. It is as simple as
use befor64 ... character(len=:), allocatable:: code64 ! base64 encoded string ... call b64_encode(n=12._R8P,code=code64) print "(A)", code64
But you are not limited to a simple integer scalar, you can encode real, integer, characters scalar or arrays, and by means of the auxiliary Lib_Pack
library also mixed types. See the wiki.
Go to Top
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
logical, | public | :: | is_b64_initialized | = | .false. | Flag for checking the initialization of the library. |
|
character(len=64), | private | :: | base64 | = | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" | Base64 alphabet. |
Encode numbers (integer and real) to base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R8P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R8P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R4P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R4P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I8P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I8P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I2P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I2P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I1P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I1P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | s | String to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar string to base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | s(1:) | String to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array string to base64.
Encode unlimited polymorphic variable to base64.
Encode unlimited polymorphic variable to base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | up(1:) | Unlimited polymorphic variable to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode an unlimited polymorphic array to base64.
Decode numbers (integer and real) from base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
real(kind=R8P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
real(kind=R8P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
real(kind=R4P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
real(kind=R4P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
integer(kind=I8P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
integer(kind=I8P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
integer(kind=I4P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
integer(kind=I4P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
integer(kind=I2P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
integer(kind=I2P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
integer(kind=I1P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
integer(kind=I1P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
character(len=*), | intent(out) | :: | s | String to be decoded. |
Decode a base64 code into a scalar string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
character(len=*), | intent(out) | :: | s(1:) | String to be decoded. |
Decode a base64 code into an array of strings.
Decode unlimited polymorphic variable from base64.
Decode unlimited polymorphic variable from base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
class(*), | intent(out) | :: | up(1:) | Unlimited polymorphic variable to be decoded. |
Decode an unlimited polymorphic array from base64.
Initialize the BeFoR64 library.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I1P), | intent(in) | :: | bits(1:) | Bits to be encoded. |
||
integer(kind=I4P), | intent(in) | :: | padd | Number of padding characters ('='). |
||
character(len=*), | intent(out) | :: | code | Characters code. |
Encode a bits stream (must be multiple of 24 bits) into base64 charcaters code (of length multiple of 4).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Characters code. |
||
integer(kind=I1P), | intent(out) | :: | bits(1:) | Bits decoded. |
Decode a base64 string into a sequence of bits stream.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | up | Unlimited polymorphic variable to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode an unlimited polymorphic scalar to base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | up(1:) | Unlimited polymorphic variable to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode an unlimited polymorphic array to base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
class(*), | intent(out) | :: | up | Unlimited polymorphic variable to be decoded. |
Decode an unlimited polymorphic scalar from base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
class(*), | intent(out) | :: | up(1:) | Unlimited polymorphic variable to be decoded. |
Decode an unlimited polymorphic array from base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R16P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (R16P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R8P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R4P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I8P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I2P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I1P), | intent(in) | :: | n | Number to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar number to base64 (I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | s | String to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode scalar string to base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R16P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (R16P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R8P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=R4P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I8P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I4P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I2P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=I1P), | intent(in) | :: | n(1:) | Array of numbers to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded array. |
Encode array numbers to base64 (I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | s(1:) | String to be encoded. |
||
character(len=:), | intent(out), | allocatable | :: | code | Encoded scalar. |
Encode array string to base64.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
real(kind=R16P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (R16P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
real(kind=R8P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
real(kind=R4P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
integer(kind=I8P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
integer(kind=I4P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
integer(kind=I2P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
integer(kind=I1P), | intent(out) | :: | n | Number to be decoded. |
Decode a base64 code into a scalar number (I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
character(len=*), | intent(out) | :: | s | String to be decoded. |
Decode a base64 code into a scalar string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
real(kind=R16P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (R16P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
real(kind=R8P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (R8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
real(kind=R4P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (R4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
integer(kind=I8P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (I8P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
integer(kind=I4P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (I4P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
integer(kind=I2P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (I2P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded array. |
||
integer(kind=I1P), | intent(out) | :: | n(1:) | Array of numbers to be decoded. |
Decode a base64 code into an array numbers (I1P).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | code | Encoded scalar. |
||
character(len=*), | intent(out) | :: | s(1:) | String to be decoded. |
Decode a base64 code into an array of strings.
Procedure for autotesting the library functionalities.