Encode a string as base64
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | str | |||
| character(len=256), | intent(out) | :: | output |
subroutine encode_string_base64(str, output) !! Encode a string as base64 use iso_fortran_env, only: int8 implicit none character(*), intent(in) :: str character(256), intent(out) :: output integer(int8), allocatable :: bytes(:) integer :: i, n n = len_trim(str) allocate(bytes(n)) do i = 1, n bytes(i) = int(ichar(str(i:i)), int8) end do call base64_encode_bytes_fixed(bytes, n, output) deallocate(bytes) end subroutine encode_string_base64